Commits

GlobalWebHq committed 81e706f Merge

Merging 2 branches

Comments (0)

Files changed (51)

Email Conversor.suo

Binary file modified.

Email Conversor/Form1.Designer.vb

         Me.Button1.Name = "Button1"
         Me.Button1.Size = New System.Drawing.Size(75, 23)
         Me.Button1.TabIndex = 0
-        Me.Button1.Text = "Convert"
+        Me.Button1.Text = "Converter"
         Me.Button1.UseVisualStyleBackColor = True
         '
         'Label1
         Me.Label1.AutoSize = True
         Me.Label1.Location = New System.Drawing.Point(12, 36)
         Me.Label1.Name = "Label1"
-        Me.Label1.Size = New System.Drawing.Size(68, 13)
+        Me.Label1.Size = New System.Drawing.Size(102, 13)
         Me.Label1.TabIndex = 1
-        Me.Label1.Text = "Select a File:"
+        Me.Label1.Text = "Selecione o Arquivo"
         '
         'TxtFilePath
         '
-        Me.TxtFilePath.Location = New System.Drawing.Point(88, 33)
+        Me.TxtFilePath.Location = New System.Drawing.Point(120, 33)
         Me.TxtFilePath.Name = "TxtFilePath"
         Me.TxtFilePath.Size = New System.Drawing.Size(184, 20)
         Me.TxtFilePath.TabIndex = 2
         Me.Label2.AutoSize = True
         Me.Label2.Location = New System.Drawing.Point(27, 74)
         Me.Label2.Name = "Label2"
-        Me.Label2.Size = New System.Drawing.Size(86, 13)
+        Me.Label2.Size = New System.Drawing.Size(91, 13)
         Me.Label2.TabIndex = 3
-        Me.Label2.Text = "Download file at "
+        Me.Label2.Text = "Baixar arquivo em"
         Me.Label2.Visible = False
         '
         'LinkLabel1
         Me.LinkLabel1.AutoSize = True
         Me.LinkLabel1.Location = New System.Drawing.Point(131, 74)
         Me.LinkLabel1.Name = "LinkLabel1"
-        Me.LinkLabel1.Size = New System.Drawing.Size(49, 13)
+        Me.LinkLabel1.Size = New System.Drawing.Size(54, 13)
         Me.LinkLabel1.TabIndex = 4
         Me.LinkLabel1.TabStop = True
-        Me.LinkLabel1.Text = "Exported"
+        Me.LinkLabel1.Text = "exportado"
         Me.LinkLabel1.Visible = False
         '
         'ProgressBar1
         '
         Me.ProgressBar1.Location = New System.Drawing.Point(15, 136)
         Me.ProgressBar1.Name = "ProgressBar1"
-        Me.ProgressBar1.Size = New System.Drawing.Size(257, 23)
+        Me.ProgressBar1.Size = New System.Drawing.Size(289, 23)
         Me.ProgressBar1.TabIndex = 5
         '
         'Label3
         Me.lblStatus.AutoSize = True
         Me.lblStatus.Location = New System.Drawing.Point(74, 108)
         Me.lblStatus.Name = "lblStatus"
-        Me.lblStatus.Size = New System.Drawing.Size(107, 13)
+        Me.lblStatus.Size = New System.Drawing.Size(156, 13)
         Me.lblStatus.TabIndex = 7
-        Me.lblStatus.Text = "Waiting for user input"
+        Me.lblStatus.Text = "Aguardando entrada do usuário"
         '
         'BackgroundWorker1
         '
         Me.BtnCancel.Name = "BtnCancel"
         Me.BtnCancel.Size = New System.Drawing.Size(75, 23)
         Me.BtnCancel.TabIndex = 8
-        Me.BtnCancel.Text = "Cancel"
+        Me.BtnCancel.Text = "Novo Arquivo"
         Me.BtnCancel.UseVisualStyleBackColor = True
         '
         'Form1
         '
         Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
         Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
-        Me.ClientSize = New System.Drawing.Size(284, 200)
+        Me.ClientSize = New System.Drawing.Size(342, 211)
         Me.Controls.Add(Me.BtnCancel)
         Me.Controls.Add(Me.lblStatus)
         Me.Controls.Add(Me.Label3)

Email Conversor/Form1.vb

         ' remaining = 999
         'Check Remaining Days
         If My.Settings.remaining_days - Date.Today.Subtract(My.Settings.start).TotalDays() < 0 Then
-            MsgBox("Your license expired")
+            MsgBox("Sua licen�a expirou")
         Else
             If remaining > 0 Then
                 'Launch New Thread
                 BackgroundWorker1.WorkerSupportsCancellation = True
                 BackgroundWorker1.RunWorkerAsync()
             Else
-                MsgBox("Not remaining conversions")
+                MsgBox("Convers�es n�o restantes")
             End If
         End If
     End Sub
 
     Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
-        If MessageBox.Show("Are you sure you want  to close the exporter?", "Close", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
+        If MessageBox.Show("Tem certeza de que deseja fechar o exportador?", "Close", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
             Login.Close()
 
         Else
         lblStatus.Text = e.UserState.ToString
         ProgressBar1.Value = e.ProgressPercentage
 
-        If e.UserState.ToString = "Conversion Finished" Then
+        If e.UserState.ToString = "Convers�o terminada" Then
             Dim remaining As Int16 = My.Settings.remaining
             remaining = remaining - 1
             My.Settings.count = My.Settings.count + 1
 
     Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
 
-        MsgBox(lblStatus.Text)
-        Button1.Enabled = True
-        BtnCancel.Enabled = False
-        TxtFilePath.Enabled = True
-       
+        'MsgBox(lblStatus.Text)
+        'Button1.Enabled = True
+        'BtnCancel.Enabled = False
+        'TxtFilePath.Enabled = True
+
     End Sub
 
     Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
 
 
   
-    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
-    End Sub
+  
 End Class

Email Conversor/Login.Designer.vb

         Me.Label2.AutoSize = True
         Me.Label2.Location = New System.Drawing.Point(25, 56)
         Me.Label2.Name = "Label2"
-        Me.Label2.Size = New System.Drawing.Size(53, 13)
+        Me.Label2.Size = New System.Drawing.Size(41, 13)
         Me.Label2.TabIndex = 2
-        Me.Label2.Text = "Password"
+        Me.Label2.Text = "Senha "
         '
         'TxtUsername
         '
         Me.Button2.Name = "Button2"
         Me.Button2.Size = New System.Drawing.Size(177, 23)
         Me.Button2.TabIndex = 9
-        Me.Button2.Text = "Clean License Info"
+        Me.Button2.Text = "Limpar informações de Licença"
         Me.Button2.UseVisualStyleBackColor = True
         '
         'Label1
         Me.Label1.AutoSize = True
         Me.Label1.Location = New System.Drawing.Point(25, 85)
         Me.Label1.Name = "Label1"
-        Me.Label1.Size = New System.Drawing.Size(87, 13)
+        Me.Label1.Size = New System.Drawing.Size(112, 13)
         Me.Label1.TabIndex = 5
-        Me.Label1.Text = "Remaining Uses:"
+        Me.Label1.Text = "Conversões restantes:"
         '
         'Label3
         '
         Me.Label3.AutoSize = True
-        Me.Label3.Location = New System.Drawing.Point(128, 85)
+        Me.Label3.Location = New System.Drawing.Point(143, 85)
         Me.Label3.Name = "Label3"
         Me.Label3.Size = New System.Drawing.Size(13, 13)
         Me.Label3.TabIndex = 6
         Me.Label4.AutoSize = True
         Me.Label4.Location = New System.Drawing.Point(25, 113)
         Me.Label4.Name = "Label4"
-        Me.Label4.Size = New System.Drawing.Size(90, 13)
+        Me.Label4.Size = New System.Drawing.Size(77, 13)
         Me.Label4.TabIndex = 7
-        Me.Label4.Text = "Remaining  Days:"
+        Me.Label4.Text = "Dias restantes:"
         '
         'Label5
         '
         Me.Label5.AutoSize = True
-        Me.Label5.Location = New System.Drawing.Point(128, 113)
+        Me.Label5.Location = New System.Drawing.Point(143, 113)
         Me.Label5.Name = "Label5"
         Me.Label5.Size = New System.Drawing.Size(13, 13)
         Me.Label5.TabIndex = 8

Email Conversor/Login.vb

     End Sub
 
     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
-        Dim result = MsgBox("Are You Sure? You will not be able to access this license anymore", MsgBoxStyle.YesNo, Nothing)
+        Dim result = MsgBox("Voc� tem certeza?", MsgBoxStyle.YesNo, Nothing)
         If result = DialogResult.Yes Then
 
             My.Settings.secret = ""

Email Conversor/Unzipper.vb

 Imports System.Runtime.InteropServices
 Imports System.Text.RegularExpressions
 Imports Redemption
-Imports System
-Imports System.IO
+Imports system.io
 
 Public Class Unzipper
-    Dim current_length As Integer = 0
+    Dim filenames As String()
     Dim zippedFile As String = ""
     Dim unzipper As New ICSharpCode.SharpZipLib.Zip.FastZip
     Dim unzipped_folder = "C:/temporary_converter"
     Dim exported_pst_correct = "C:\temp\exported.pst"
     Dim extra_path = "http_80"
     Dim backslash = "/"
-    Dim Dnought As DateTime = #1/1/1970#
-    Dim ContentType As String = ""
     Dim database = "database-test#database"
     Dim attachment_folder = "test-store[1]#localserver/"
     Dim conn_string As String = ""
     Dim folder_name As String = "Inbox"
     Dim file_name_folder As String = "exporter"
+    Dim ContentType As String
+    Dim filenamecount = 0
     Dim worker As System.ComponentModel.BackgroundWorker
-    Dim RDOxSession As Redemption.RDOSession
     Public Sub New(ByVal Value As String, ByRef bgWorker As System.ComponentModel.BackgroundWorker)
         Me.zippedFile = Value
         Me.worker = bgWorker
 
         If Me.zippedFile.Length > 0 Then
             '0 % Unzipping
-            Me.worker.ReportProgress(0, "Unzipping")
+            Me.worker.ReportProgress(0, "Descompactando")
             Me.Unzip()
-            Me.worker.ReportProgress(15, "Searching")
+            Me.worker.ReportProgress(15, "Pesquisando")
             '15% Searching 
             '20% Processing x/y    
             Me.SearchForSqlLiteFiles()
         Me.file_name_folder = System.IO.Path.GetFileNameWithoutExtension(Me.zippedFile)
         Me.exported_pst = "C:/temp/" + Me.file_name_folder + ".pst"
         Me.exported_pst_correct = "C:\temp\" + Me.file_name_folder + ".pst"
+        Me.unzipped_folder = Me.unzipped_folder
         unzipper.ExtractZip(Me.zippedFile, Me.unzipped_folder, "")
 
 
         Dim attachment_files As String
         GetDirectories(Me.unzipped_folder, DirList)
         DirList.Add(unzipped_folder)
+
         Dim Found As Boolean = False
         For Each item In DirList
-            If item.EndsWith(extra_path) Then
+
+            If item.EndsWith(extra_path) Or item.EndsWith(extra_path + "/") Or item.EndsWith(extra_path + "\") Then
+                Me.worker.ReportProgress(21, "Processamento...")
                 db_file = item + backslash + database
                 attachment_files = item + backslash + attachment_folder
+
                 exists = System.IO.File.Exists(db_file)
                 'Database Exists , Convert
+
                 If exists Then
                     Found = Me.CreatePST(db_file, attachment_files)
+                Else
+
                 End If
             End If
 
         Next
         If Not Found Then
-            Me.worker.ReportProgress(100, "No Files to export")
+            Me.worker.ReportProgress(100, "No h� arquivos para exportar")
         End If
 
     End Sub
-    Private Sub DeleteFiles()
-        System.IO.Directory.Delete(unzipped_folder, True)
-    End Sub
-    Private Function CreatePST(ByVal db_file As String, ByVal attachment_files As String) As Boolean
-        'Create pst file
-        'Counters
-        Dim total_count = 0
-        Dim current_count = 0
-        Dim rdr As SQLite.SQLiteDataReader = Nothing
-        Dim app As Outlook.Application = Nothing
-        Dim ns As Outlook.NameSpace = Nothing
-        Me.conn_string = "data source=""" + db_file + """"
-        Dim conn As SQLite.SQLiteConnection = New SQLite.SQLiteConnection(conn_string)
-        '   
-        ' Init File
-        Try
-            app = New Outlook.Application()
-            ns = app.GetNamespace("MAPI")
-
+    Public Function GetFileContents(ByVal FullPath As String, _
+      Optional ByRef ErrInfo As String = "") As String
 
+        Dim strContents As String
+        Dim objReader As StreamReader
+        Try
 
-        Catch ex As Exception
+            objReader = New StreamReader(FullPath)
+            strContents = objReader.ReadToEnd()
+            objReader.Close()
+            Return strContents
+        Catch Ex As Exception
+            ErrInfo = Ex.Message
+            Return ""
 
         End Try
-        Me.RDOxSession = CreateObject("Redemption.RDOSession")
-        Dim store As Redemption.RDOPstStore = RDOxSession.LogonPstStore(Me.exported_pst, rdoStoreType.olStoreUnicode)
-        Dim rdoMapiUtils As Redemption.MAPIUtils = New Redemption.MAPIUtils
-        Dim targetFolder As Redemption.RDOFolder
-        'Iterate through Files
-
-        Dim filenames As String() = System.IO.Directory.GetFiles(attachment_files, "fonte_da_mensagem*.txt")
-        Dim folderName As String = "inbox"
-
-        conn.Open()
-        total_count = filenames.Length
-        For Each filename As String In filenames
-            Dim sql_folder As String = "select *  from mail LIMIT " + current_count.ToString() + ",1"
-            Dim sql_folder_command As SQLite.SQLiteCommand = New SQLite.SQLiteCommand(sql_folder, conn)
-
-            Try
-
-                rdr = sql_folder_command.ExecuteReader()
-                rdr.Read()
-                folderName = rdr.GetString(2)
-            Catch ex As Exception
-                MsgBox(ex.Message)
-            End Try
-
-            Try
-                targetFolder = RDOxSession.GetDefaultFolder(rdoDefaultFolders.olFolderInbox).Folders.Add(folderName)
-            Catch ex As Exception
-                targetFolder = store.GetDefaultFolder(rdoDefaultFolders.olFolderInbox).Folders.Item(folderName)
-            End Try
-
-            current_count = current_count + 1
-
-
-            Dim oMsg As Redemption.RDOMail = targetFolder.Items.Add("IPM.Note")
-            If retrieve_message(filename, targetFolder, oMsg, rdr) Then
-
-            End If
-           
-            Me.worker.ReportProgress((20 + (current_count \ total_count) * 80), "Converting " + current_count.ToString() + " of " + total_count.ToString())
-        Next
-
-        ''Clean All
-        RDOxSession.Logoff()
-        rdoMapiUtils.Cleanup()
-        'Report
-        Me.worker.ReportProgress(100, "Conversion Finished")
-        conn.Close()
-        Return True
-    End Function
-    Public Function ConvertUtf8ToLatin1(ByVal original As String) As String
-        Dim target As String
-        target = original
-        target = target.Replace("=?iso-8859-1?Q?", "")
-        target = target.Replace("=5F", "_")
-
-        target = target.Replace("=C9", "�")
-
-        target = target.Replace("=E1", "�")
-        target = target.Replace("=E3", "�")
-
-        target = target.Replace("=E7", "�")
-
-        target = target.Replace("=ED", "�")
-
-        target = target.Replace("=F5", "�")
-        target = target.Replace("=FA", "�")
-        target = target.Replace("=3D", "=")
-
-
-
-        target = target.Replace("?=", "")
-        Return target
     End Function
     Public Sub addHeader(ByRef oMsg As Redemption.RDOMail, ByVal header As String, ByVal headerValue As String)
+        Dim Proptag As Integer
         If header <> "" And headerValue <> "" Then
-            'Adding From
             If header = "From" Then
-                Dim User As RDOAddressEntry = Me.RDOxSession.CurrentUser
-                Dim ffromS As String() = headerValue.Split("<")
 
-                If ffromS.Length > 1 Then
-                    User.Name = ConvertUtf8ToLatin1(ffromS.GetValue(0).ToString().Trim())
-                    User.Address = ffromS.GetValue(1).ToString().Replace("<", "").Replace(">", "").Trim()
-                Else
-                    User.Address = headerValue
-                End If
-                oMsg.Sender = User
-                oMsg.SentOnBehalfOf = User
                 Return
             End If
             'Adding To
             If header = "To" Then
-                oMsg.To = headerValue
+               
+              
                 Return
             End If
             'Adding CC
             If header = "Cc" Then
-                oMsg.CC = headerValue
-                Return
-            End If
-            'Adding BCC
-            If header = "Bcc" Then
-                oMsg.BCC = headerValue
+         
+
                 Return
             End If
+
             'Adding Subject
             If header = "Subject" Then
-                oMsg.Subject = ConvertUtf8ToLatin1(headerValue)
+
                 Return
             End If
             'Adding Date
             If header = "Date" Then
-                Dim sentOn As DateTime = New DateTime()
-                oMsg.SentOn = DateTime.ParseExact(headerValue.Trim(), "ddd, d MMM yyyy HH:mm:ss zzz", Nothing)
-                oMsg.ReceivedTime = DateTime.ParseExact(headerValue.Trim(), "ddd, d MMM yyyy HH:mm:ss zzz", Nothing)
+
+                Return
+            End If
+            'Adding BCC
+            If header = "Bcc" Then
+                ' Proptag = oMsg.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}", header)
+                'Proptag = Proptag Or &H1E
+                'oMsg.Fields(Proptag) = headerValue
                 Return
             End If
             'Content type
             If header = "Content-Type" Then
                 Me.ContentType = headerValue
-                Return
+                Proptag = oMsg.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}", header)
+                Proptag = Proptag Or &H1E
+                oMsg.Fields(Proptag) = headerValue
             End If
             'Adding X-Headers
-            Dim Proptag As Object = oMsg.GetIDsFromNames("{00020329-0000-0000-C000-000000000046}", header) Or &H1E
-            oMsg.Fields(Proptag) = headerValue
 
 
-            'Dim oPrp As Object = oMsg.UserProperties.Add(header, 1)
-            'oPrp.Value = headerValue
-            'Return
+            Proptag = oMsg.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}", header)
+            Proptag = Proptag Or &H1E
+            oMsg.Fields(Proptag) = headerValue
 
 
         End If
 
     End Sub
-    Function retrieve_message(ByVal filename As String, ByRef targetFolder As Redemption.RDOFolder, ByRef oMsg As Redemption.RDOMail, ByRef rdr As SQLite.SQLiteDataReader) As Boolean
-        Dim sErr As String = ""
-        Dim sContents As String = GetFileContents(filename, sErr)
-        If sErr = "" Then
-            'Divide between headers and body
-            Dim position As Integer = sContents.IndexOf(vbNewLine + vbNewLine + vbNewLine)
-            Dim headers As String = sContents.Substring(0, position)
-            Dim body As String = sContents.Substring(position)
-            'Parse Headers
-            Dim headersLines As String() = headers.Split(vbNewLine)
-            Dim temp As String = ""
-            Dim header As String = ""
-            Dim check As String = ""
-            Dim dotPosition As Integer
-            'Set some params
-
-            'Get Body from db, is better
-            oMsg.BodyFormat = Outlook.OlBodyFormat.olFormatHTML
-            oMsg.HTMLBody = rdr.GetString(12)
-            oMsg.Subject = oMsg.Subject + rdr.GetString(9)
-            oMsg.ReadReceiptRequested = True
-            oMsg.OriginatorDeliveryReportRequested = True
-            oMsg.Sent = True
-
-            For Each headersLine As String In headersLines
-                Try
-             
-                    headersLine = headersLine.Replace(vbLf, "").Replace(vbCr, "")
-                    check = headersLine.Substring(0, 1)
-                    If check = vbTab Or check = " " Then
-                        'This is not a header!!!, just append content
-                        temp = temp + headersLine
-                    Else
-                        'This is a header
-                        'Position of :
-                        Me.addHeader(oMsg, header, temp)
-                        dotPosition = headersLine.IndexOf(":")
-                        temp = headersLine.Substring(dotPosition + 1)
-                        header = headersLine.Substring(0, dotPosition)
+    Private Sub DeleteFiles()
+        Try
+            System.IO.Directory.Delete(unzipped_folder, True)
+        Catch ex As Exception
 
-                    End If
-                Catch ex As Exception
-                    MsgBox(ex.Message)
-                End Try
-            Next
-            Me.addHeader(oMsg, header, temp)
-            MsgBox(oMsg.ReceivedTime.Subtract(Dnought).Seconds)
+        End Try
+
+    End Sub
+    Private Sub addHeaderAndAttachment(ByVal Size As Integer, ByRef oMsg As Redemption.RDOMail)
+        Dim temp As String = ""
+        Dim header As String = ""
+        Dim check As String = ""
+        Dim dotPosition As Integer
+        For Each filename As String In filenames
+            Dim info As New System.IO.FileInfo(filename)
+
+
+            If (info.Length - Size = 4) Then
+                Me.filenamecount = Me.filenamecount + 1
+
+                'Here we add Attachments and headers
+                Dim sErr As String = ""
+                Dim sContents As String = GetFileContents(filename, sErr)
+                If sErr = "" Then
+                    Dim position As Integer = sContents.IndexOf(vbNewLine + vbNewLine + vbNewLine)
+                    Dim headers As String = sContents.Substring(0, position)
+                    Dim body As String = sContents.Substring(position)
+                    'Parse Headers
+                    Dim headersLines As String() = headers.Split(vbNewLine)
+                    For Each headersLine As String In headersLines
+                        Try
+
+                            headersLine = headersLine.Replace(vbLf, "").Replace(vbCr, "")
+                            check = headersLine.Substring(0, 1)
+                            If check = vbTab Or check = " " Then
+                                'This is not a header!!!, just append content
+                                temp = temp + vbNewLine + headersLine
+                            Else
+                                'This is a header
+                                'Position of :
+                                Me.addHeader(oMsg, header, temp)
+                                dotPosition = headersLine.IndexOf(":")
+                                temp = headersLine.Substring(dotPosition + 1)
+                                header = headersLine.Substring(0, dotPosition)
+
+                            End If
+                        Catch ex As Exception
+
+                            'MsgBox(headers)
+                        End Try
+                    Next
+                    Me.addHeader(oMsg, header, temp)
+                    Try
+                        parseBody(body, oMsg)
+                    Catch ex As Exception
+                        'MsgBox(body)
+                        'MsgBox(ex.Message)
+                    End Try
+                End If
+                'Top end if
+            End If
+        Next
+    End Sub
+    Public Function SearchForFile(ByVal attachment_files As String, ByVal filename As String, ByVal ext As String) As String
+        Dim found As String() = System.IO.Directory.GetFiles(attachment_files, filename & "*" & ext, System.IO.SearchOption.AllDirectories)
+        If found.Length > 0 Then
+            Return found(0)
+        End If
+        Return ""
+    End Function
+    Private Function CreatePST(ByVal db_file As String, ByVal attachment_files As String) As Boolean
+
+        filenames = System.IO.Directory.GetFiles(attachment_files, "fonte_da_mensagem*.txt", System.IO.SearchOption.AllDirectories)
+
+        'Create pst file
+
+        Dim total_count = 0
+        Dim current_count = 0
+        Dim targetFolder As Redemption.RDOFolder
+        'Dim movedMail As Redemption.RDOMail
+        Dim store As Redemption.RDOPstStore
+        Dim Dnought As DateTime = #1/1/1970#
+
+        'Read the db file
+        Me.conn_string = "data source=""" + db_file + """"
+
+        Dim sql_folders As String = "select folder from folder LIMIT 1"
+
+        Dim sql_messages As String = "select *  from mail"
+
+        Dim sql_total As String = "select count(*)  from mail"
+        Dim rdoMapiUtils As Redemption.MAPIUtils
+        rdoMapiUtils = New Redemption.MAPIUtils
+
+        Dim conn As SQLite.SQLiteConnection = New SQLite.SQLiteConnection(conn_string)
+
+        Dim RDOxSession As Redemption.RDOSession = CreateObject("Redemption.RDOSession")
+
+        store = RDOxSession.LogonPstStore(Me.exported_pst, rdoStoreType.olStoreUnicode)
+
+
+        Dim sql_folders_command As SQLite.SQLiteCommand = New SQLite.SQLiteCommand(sql_folders, conn)
+        Dim sql_messages_command As SQLite.SQLiteCommand = New SQLite.SQLiteCommand(sql_messages, conn)
+        Dim sql_total_command As SQLite.SQLiteCommand = New SQLite.SQLiteCommand(sql_total, conn)
+        Dim rdr As SQLite.SQLiteDataReader = Nothing
+
+        conn.Open()
+        '  Try
+        'Dim x As String = sql_folders_command.ExecuteScalar()
+
+        '   If Not IsDBNull(x) Then
+        'folder_name = x
+        '   End If
+        '  Catch ex As Exception
+
+        '   End Try
+
+        Try
+            rdr = sql_messages_command.ExecuteReader()
+        Catch ex As Exception
+
+        End Try
+
+        Try
+            total_count = sql_total_command.ExecuteScalar()
+
+
+        Catch ex As Exception
+            total_count = 1
+
+        End Try
+        'Open existing file
+        Dim subject As String = ""
+
+        While rdr.Read()
 
             Try
-                parseBody(body, oMsg)
+                targetFolder = RDOxSession.GetDefaultFolder(rdoDefaultFolders.olFolderInbox).Folders.Add(rdr.GetString(2))
+
             Catch ex As Exception
-                MsgBox(ex.Message)
+                targetFolder = store.GetDefaultFolder(rdoDefaultFolders.olFolderInbox).Folders.Item(rdr.GetString(2))
+
             End Try
-            oMsg.Save()
+            Try
+                Dim ffrom As String = rdr.GetString(8)
+                ffrom = ffrom.Substring(ffrom.IndexOf("full") + 7)
+                ffrom = ffrom.Substring(0, ffrom.IndexOf(";}") - 1)
+                ffrom = ffrom.Substring(ffrom.IndexOf(ControlChars.Quote) + 1)
+                ffrom = ffrom.Replace("&lt;", "<")
+                ffrom = ffrom.Replace("&gt;", ">")
+                Dim Proptag As Integer
+                ' Dim omUser As Outlook.Recipient = app.Session.CreateRecipient(ffrom)
+
+
+                '  omUser.Resolve()
+                '  omUser.AddressEntry.Update(True)
+
+                Dim ccString As String = rdr.GetString(11)
+                ccString = ccString.Replace("&lt;", "<")
+                ccString = ccString.Replace("&gt;", ">")
+                Dim toString As String = rdr.GetString(10)
+                toString = toString.Replace("&lt;", "<")
+                toString = toString.Replace("&gt;", ">")
+                toString = toString.Substring(toString.IndexOf(ControlChars.Quote) + 1)
+                toString = toString.Substring(0, toString.IndexOf(";") - 1)
+
+                current_count = current_count + 1
+                ''Add messages
+
+                'Dim oMsg As Outlook._MailItem = app.CreateItem(Outlook.OlItemType.olMailItem)
+                'Dim oMsg As Redemption.SafeMailItem = CreateObject("Redemption.SafeMailItem")
+                Dim oMsg As Redemption.RDOMail = targetFolder.Items.Add("IPM.Note")
+                ' oMsg.MessageClass = "IPM.Note"
+
+                subject = rdr.GetString(9)
+                oMsg.Subject = subject
+                oMsg.BodyFormat = Outlook.OlBodyFormat.olFormatHTML
+                If ccString <> "N;" Then
+                    ccString = ccString.Substring(ccString.IndexOf(ControlChars.Quote) + 1)
+                    ccString = ccString.Substring(0, ccString.IndexOf(";") - 1)
+                    oMsg.CC = ccString
+                    'Proptag = oMsg.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}", "Cc")
+                    'Proptag = Proptag Or &H1E
+                    'oMsg.Fields(Proptag) = ccString
+                    'For Each ccUser As String In ccString.Split(",")
+                    '    Dim ccUserObject As Outlook.ContactItem = app.CreateItem(Outlook.OlItemType.olContactItem)
+                    '    Dim temp As String() = ccUser.Split(ControlChars.Quote + " ")
+                    '    ccUserObject.Email1Address = temp.GetValue(2).ToString().Replace("<", "").Replace(">", "")
+                    '    ccUserObject.Email1DisplayName = temp.GetValue(1)
+                    '    ccUserObject.Move(targetFolder).Save()
+                    'Next
+                End If
 
-            Return True
-        End If
+                oMsg.HTMLBody = rdr.GetString(12)
+
+                oMsg.ReadReceiptRequested = True
+                oMsg.OriginatorDeliveryReportRequested = True
+                Dim Dfinal As DateTime = Dnought.AddSeconds(rdr.GetInt64(4))
+                oMsg.ExpiryTime = Dfinal
+                Dim User As RDOAddressEntry = RDOxSession.CurrentUser
+                Dim ffromS As String() = ffrom.Split(ControlChars.Quote + " ")
+                If ffromS.Length > 1 Then
+                    User.Name = ffromS.GetValue(1)
+                    User.Address = ffromS.GetValue(2).ToString().Replace("<", "").Replace(">", "")
+                Else
+                    User.Address = ffrom
+                End If
+                oMsg.Sender = User
+                oMsg.SentOnBehalfOf = User
+                'MsgBox(omUser.AddressEntry.Address)
+                'Dim ffromUserObject As Outlook.ContactItem = app.CreateItem(Outlook.OlItemType.olContactItem)
+
+                'ffromUserObject.Move(targetFolder).Save()
+                '    oMsg.SentOnBehalfOfName = ffrom
+                oMsg.ReceivedTime = Dfinal
+                '
+                oMsg.To = toString.Replace(ControlChars.Quote, "")
+                For Each userToString As String In toString.Replace(ControlChars.Quote, "").Split(",")
+                    Dim UserTo As RDOAddressEntry = RDOxSession.CurrentUser
+                    Dim userToStringX As String() = userToString.Split(ControlChars.Quote + " ")
+                    If userToStringX.Length > 1 Then
+                        UserTo.Name = userToStringX.GetValue(1)
+                        UserTo.Address = userToStringX.GetValue(2).ToString().Replace("<", "").Replace(">", "")
+                    Else
+                        UserTo.Address = userToString
+                    End If
+                Next
+                'Create to contacts
+                'For Each toUser As String In toString.Split(",")
+                '    Dim toUserObject As Outlook.ContactItem = app.CreateItem(Outlook.OlItemType.olContactItem)
+                '    Dim temp As String() = toUser.Split(ControlChars.Quote + " ")
+                '    toUserObject.Email1Address = temp.GetValue(2).ToString().Replace("<", "").Replace(">", "")
+                '    toUserObject.Email1DisplayName = temp.GetValue(1)
+                '    toUserObject.Move(targetFolder).Save()
+                'Next
+
+               
+                Me.worker.ReportProgress((20 + (current_count / total_count) * 80), "Convertendo  " + current_count.ToString() + " of " + total_count.ToString())
+                'Dim myAddressEntry As CDO.AddressEntry
+                'oMsg.Sender = "gxdssoft@gmail.com"
+
+                'Dim attach As String = rdr.GetString(0)
+                'attach = attach.Substring(0, attach.IndexOf("encoding") - 6)
+                'attach = attach.Substring(attach.IndexOf("name") + 9)
+                'attach = attach.Substring(attach.IndexOf(ControlChars.Quote) + 1)
+                'attach = attach.Substring(0, attach.LastIndexOf(ControlChars.Quote) - 1)
+                oMsg.Sent = True
+                oMsg.SentOn = Dfinal
+
+
+                ' Dim sSource As String = attachment_files + attach
+                ' MsgBox(sSource)
+                'Dim sDisplayName As String = attach
+                ' Dim sBodyLen As String = +oMsg.HTMLBody.Length
+                'Attachments
+                ' Dim oAttachs As Outlook.Attachments = oMsg.Attachments
+                '  Dim oAttach As Outlook.Attachment
+                '  oAttach = oAttachs.Add(sSource, , sBodyLen + 1, sDisplayName)
+
+                addHeaderAndAttachment(rdr.GetInt32(13), oMsg)
+              
+                Proptag = oMsg.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}", "To")
+                Proptag = Proptag Or &H1E
+                oMsg.Fields(Proptag) = toString
+                oMsg.To = toString
+                'Add Attachment from db
+
+                oMsg.Save()
+                oMsg.Send()
+                oMsg.SentOn = Dfinal
+                oMsg.Save()
+
+            Catch ex As Exception
+                'MsgBox(ex.Message)
+                'MsgBox(ex.StackTrace)
+            End Try
+        End While
+
+        store.Save()
+
+        RDOxSession.Logoff()
 
-        Return False
+        rdoMapiUtils.Cleanup()
+        conn.Close()
+        'MsgBox(Me.filenamecount)
+        Me.worker.ReportProgress(100, "Convers�o terminada")
+        Return True
     End Function
-    Public Sub parseBody(ByVal body As String, ByRef oMsg As Redemption.RDOMail)
-        'If Me.ContentType.Contains("text/html") Then
 
-        '    oMsg.HTMLBody = ConvertUtf8ToLatin1(body)
-        '    Return
-        'End If
-        'If Me.ContentType.Contains("text/plain") Then
+    Sub GetDirectories(ByVal StartPath As String, ByRef DirectoryList As ArrayList)
+        Dim Dirs() As String = System.IO.Directory.GetDirectories(StartPath)
+        DirectoryList.AddRange(Dirs)
+
+        For Each Dir As String In Dirs
+            GetDirectories(Dir, DirectoryList)
+        Next
+    End Sub
+    Public Sub parseBody(ByVal body As String, ByRef oMsg As Redemption.RDOMail)
 
-        '    oMsg.Body = ConvertUtf8ToLatin1(body)
-        '    Return
-        'End If
         If Me.ContentType.Contains("multipart") Then
             Dim boundary As String = Me.ContentType.Substring(Me.ContentType.IndexOf("boundary=") + 9).Replace(ControlChars.Quote, "")
             processMultiPart(body, boundary, oMsg)
         End If
     End Sub
     Public Sub processMultiPart(ByVal body As String, ByVal Boundary As String, ByRef oMsg As Redemption.RDOMail)
-        '.Substring(Me.ContentType.IndexOf("boundary=") + 9).Replace(ControlChars.Quote, "")
-        'Match First Boundary
-        Dim position As Integer = 1
-        Dim inthelperstart As Integer = 0
-        Dim inthelperstop As Integer = 0
-        Dim strBoundary As String = ""
-        Dim tmpBoundary As String = ""
-        Dim temp As String = ""
-        While (position > 0)
-            strBoundary = "--" + Boundary
-            tmpBoundary = Boundary
-            'position = body.IndexOf(strBoundary) + strBoundary.Length + 2
-            'Check if boundary changed, if so update body and boundary
-            'body = body.Substring(position)
-            If (body.IndexOf("boundary=") > 0) Then
-                inthelperstart = body.IndexOf("boundary=") + 9
-                inthelperstop = body.Substring(inthelperstart).IndexOf(vbNewLine)
-                tmpBoundary = body.Substring(inthelperstart, inthelperstop)
-                strBoundary = "--" + tmpBoundary
-                body = body.Substring(body.IndexOf(strBoundary))
-            End If
-            
-            ''Add each Item
-            inthelperstart = body.IndexOf("--" + tmpBoundary)
-            inthelperstop = body.IndexOf("--" + tmpBoundary + "--")
-            'Extract Miniaml chunk
-            temp = body.Substring(inthelperstart + ("--" + tmpBoundary).Length, inthelperstop - 1)
-            addAttachment(temp, "--" + tmpBoundary, oMsg)
-            'Update body
-            body = body.Substring(inthelperstop + ("--" + tmpBoundary + "--").Length + 1)
-
-            ''Update position
-            position = body.IndexOf("--" + Boundary)
-
 
-
-        End While
+        Dim RegexObj As Regex = New Regex("Content-Type:.{0,120}name=" & ControlChars.Quote & "(.*?)" & ControlChars.Quote & ".*?" & vbNewLine & vbNewLine & "(.*?)(\n)*--", RegexOptions.Singleline)
+        Dim matches As MatchCollection = RegexObj.Matches(body)
+        If matches.Count() > 0 Then
+            For Each match As Match In matches
+                If match.Success Then
+                    Dim attachments As Redemption.RDOAttachments = oMsg.Attachments
+
+                    Dim name As String = match.Groups(1).Value
+                    Dim regexSearch As String = New String(Path.GetInvalidFileNameChars()) + New String(Path.GetInvalidPathChars())
+
+                    Dim r As Regex = New Regex(String.Format("[{0}]", Regex.Escape(regexSearch)))
+                    name = r.Replace(name, "")
+                    'MsgBox(name)
+                    Dim content As String = match.Groups(2).Value
+                    Dim binaryData() As Byte = Convert.FromBase64String(content)
+
+                    Dim fs As New FileStream(name, FileMode.CreateNew)
+                    fs.Write(binaryData, 0, binaryData.Length)
+                    fs.Close()
+                    Dim oAttach As Redemption.RDOAttachment
+                    oAttach = attachments.Add(name)
+                    System.IO.File.Delete(name)
+                   
+                End If
+            Next
+        End If
+        
+        ''.Substring(Me.ContentType.IndexOf("boundary=") + 9).Replace(ControlChars.Quote, "")
+        ''Match First Boundary
+        'Dim inthelperstart As Integer = 0
+        'Dim inthelperstop As Integer = 0
+        'Dim secondBoundary As String = ""
+        'Dim tmpBoundary As String = ""
+        'Dim secondBody As String = ""
+        'Dim content As String = ""
+        'If (body.IndexOf("boundary=") > 0) Then
+        '    inthelperstart = body.IndexOf("boundary=") + 9
+        '    inthelperstop = body.Substring(inthelperstart).IndexOf(vbNewLine)
+        '    tmpBoundary = body.Substring(inthelperstart, inthelperstop)
+        '    secondBoundary = tmpBoundary
+        '    body = body.Substring(body.IndexOf(secondBoundary))
+        'End If
+        'secondBody = body
+
+        ' ''Search for first boundary
+        'inthelperstart = body.IndexOf("--" + Boundary)
+
+        'While (inthelperstart > 0)
+        '    content = body.Substring(inthelperstart + ("--" + Boundary).Length)
+        '    inthelperstop = content.IndexOf("--" + Boundary + "--")
+        '    If inthelperstop > 0 Then
+        '        content = content.Substring(0, inthelperstop - 1)
+        '        addAttachment(content, Boundary, oMsg)
+        '        body = body.Substring(inthelperstop + ("--" + Boundary + "--").Length)
+        '        inthelperstart = body.IndexOf("--" + Boundary)
+        '    Else
+        '        inthelperstart = 0
+        '    End If
+
+
+        'End While
+
+        ' ''Search for second boundary
+        'inthelperstart = secondBody.IndexOf("--" + secondBoundary)
+        'If secondBoundary.Length > 0 Then
+        '    While (inthelperstart > 0)
+        '        content = secondBody.Substring(inthelperstart + ("--" + secondBoundary).Length)
+        '        inthelperstop = content.IndexOf("--" + secondBoundary + "--")
+
+        '        If inthelperstop > 0 Then
+
+        '            content = content.Substring(0, inthelperstop - 1)
+        '            addAttachment(content, secondBoundary, oMsg)
+        '            secondBody = secondBody.Substring(inthelperstop + ("--" + secondBoundary + "--").Length)
+        '            inthelperstart = secondBody.IndexOf("--" + secondBoundary)
+        '        Else
+        '            inthelperstart = 0
+        '        End If
+        '    End While
+        'End If
 
 
     End Sub
         Dim position As Integer = 0
         Dim newcontent As String = ""
         Dim cleanwhere As Integer = 2
+
         If content.Trim().StartsWith("Content-Type: text/plain") Then
             ''Text Plain 
             Dim lines As String() = content.Split(vbNewLine)
 
             Return
         End If
-        If content.Trim().StartsWith("Content-Type") Then
+        If content.Trim().StartsWith("Content") Then
             'Get the name
             position = content.IndexOf("name=")
             Dim name As String = content.Substring(position + 6)
             System.IO.File.Delete(name)
         End If
     End Sub
-
-    Public Function GetFileContents(ByVal FullPath As String, _
-       Optional ByRef ErrInfo As String = "") As String
-
-        Dim strContents As String
-        Dim objReader As StreamReader
-        Try
-
-            objReader = New StreamReader(FullPath)
-            strContents = objReader.ReadToEnd()
-            objReader.Close()
-            Return strContents
-        Catch Ex As Exception
-            ErrInfo = Ex.Message
-            Return ""
-        End Try
-    End Function
-    Sub GetDirectories(ByVal StartPath As String, ByRef DirectoryList As ArrayList)
-        Dim Dirs() As String = System.IO.Directory.GetDirectories(StartPath)
-        DirectoryList.AddRange(Dirs)
-
-        For Each Dir As String In Dirs
-            GetDirectories(Dir, DirectoryList)
-        Next
-    End Sub
 End Class

Email Conversor/bin/x86/Debug/Email Conversor.exe

Binary file modified.

Email Conversor/bin/x86/Debug/Email Conversor.pdb

Binary file modified.

Email Conversor/bin/x86/Debug/Interop.Redemption.dll

Binary file modified.

Email Conversor/bin/x86/Debug/temporary_converter/Teste/cw0fx5yf.default/Cache/001E39A4d01

+ var openTab = {
+	'type' : [], // 8 types of tabs, further info. see expressolivre.org/dev/wiki/mail/Documentacao
+	'content_id' : [],
+	'imapUid' : [], // Stores the imap email number of current tab
+	'countFile' : [0,0,0,0,0,0,0,0,0,0], // Stores the number of files attached in current tab
+	'imapBox' : [], // Stores the folder name
+	'toPreserve' : [], // Check if the message should be removed from draft after send
+	'autosave_timer' : [] // The timeout timer for autosave function
+};
+var tabTypes = {
+	'new':4,
+	'forward':6,
+	'reply_with_history':7,
+	'reply_to_all_with_history':8,
+	'reply_without_history':9,
+	'reply_to_all_without_history':10,
+	'edit':5
+	}
+var currentTab,numBox = 0; // Open Tab and num of mailboxes opened at context
+// Objeto Map, talvez o ideal fosse adicionar este objeto � Api do egroupware, e carreg�-lo
+// aqui no expressoMail.
+function Map()
+{
+	this.keys = new Array();
+	this.values = new Array();
+}
+
+Map.prototype.add = function(key, value)
+{
+	this.keys.push(key);
+	this.values.push(value);
+}
+
+Map.prototype.get = function(key)
+{
+	result = new Array();
+	for (i = 0; i < this.keys.length; i++)
+	{
+		if (this.keys[i] == key)
+		{
+			result.push(this.values[i]);
+		}
+	}
+
+	if (result.length == 0)
+	{
+		return null;
+	}
+
+	return result;
+}
+
+var translatedFolders = new Map();
+
+function draw_tree_folders(folders){
+	// Check if the tree folders alredy exist.
+		translatedFolders = new Map();
+	if (Element('dftree_tree_folders')){
+		if (!expresso_offline) {
+			var update_tree_folders = function(data){
+				build_quota(data);
+				var unseen_in_mailbox = 0;
+				var unseen_in_shared_folders = 0;
+				for (var i=0; i<data.length; i++){
+					if ( data[i].folder_unseen > 0 )
+					{
+						unseen_in_mailbox = parseInt( unseen_in_mailbox + data[ i ].folder_unseen );
+						if ( data[i].folder_id.indexOf( 'INBOX' ) !== 0 )
+							unseen_in_shared_folders = parseInt( unseen_in_shared_folders + data[ i ].folder_unseen );
+					}
+
+					var folder_unseen = Element('dftree_'+data[i].folder_id+'_unseen');
+
+					if ((folder_unseen) && (data[i].folder_unseen > 0))
+					{
+						folder_unseen.innerHTML = data[i].folder_unseen;
+					}
+					else if (data[i].folder_unseen > 0)
+					{
+						tree_folders.getNodeById(data[i].folder_id).alter({caption:lang_folder(data[i].folder_name) + '<font style=color:red>&nbsp(</font><span id="dftree_'+data[i].folder_id+'_unseen" style=color:red>'+data[i].folder_unseen+'</span><font style=color:red>)</font>'});
+						tree_folders.getNodeById(data[i].folder_id)._refresh();
+					}
+					else if (data[i].folder_unseen <= 0)
+					{
+						tree_folders.getNodeById(data[i].folder_id).alter({caption:lang_folder(data[i].folder_name)});
+						tree_folders.getNodeById(data[i].folder_id)._refresh();
+					}
+
+					if(data[i].folder_id == current_folder){
+						var old_new_m = isNaN(parseInt(Element('new_m').innerHTML)) ? parseInt(Element('new_m').firstChild.innerHTML) : parseInt(Element('new_m').innerHTML);
+						Element('new_m').innerHTML = data[i].folder_unseen ? '<font color="RED">'+data[i].folder_unseen+'</font>' : 0;
+						draw_paging(Element('tot_m').innerHTML);
+					}
+				}
+
+				var display_unseen_in_mailbox = tree_folders.getNodeById( 'root' );
+				display_unseen_in_mailbox.alter({caption:get_lang("My Folders")});
+				display_unseen_in_mailbox._refresh();
+
+				var display_unseen_in_shared_folders = tree_folders.getNodeById( 'user' );
+				if ( display_unseen_in_shared_folders )
+				{
+					if ( unseen_in_shared_folders )
+						display_unseen_in_shared_folders.alter({caption:'<font style=color:red>[</font><span id="dftree_user_unseen" style="color:red">' + unseen_in_shared_folders +'</span><font style=color:red>]</font> ' + get_lang("Shared folders")});
+					else
+						display_unseen_in_shared_folders.alter({caption:get_lang("Shared folders")});
+					display_unseen_in_shared_folders._refresh();
+				}
+			}
+			cExecute ("$this.imap_functions.get_folders_list&folder="+current_folder, update_tree_folders);
+		}
+
+		return;
+	}
+	else{
+		if (!expresso_offline)
+		{
+                    tree_folders = new dFTree({name: 'tree_folders'});
+
+                    var n_root = new dNode({id:'root', caption: get_lang("My Folders")});
+                    tree_folders.add(n_root,'anything'); //Places the root; second argument can be anything.
+
+                    var unseen_in_mailbox = 0;
+                    var unseen_in_shared_folders = 0;
+                    for (var i=0; i<folders.length; i++)
+                    {
+                        if (folders[i].folder_unseen > 0)
+                        {
+                                unseen_in_mailbox = parseInt( unseen_in_mailbox + folders[ i ].folder_unseen );
+                                if ( folders[i].folder_id.indexOf( 'INBOX' ) !== 0 )
+                                        unseen_in_shared_folders = parseInt( unseen_in_shared_folders + folders[ i ].folder_unseen );
+
+                                var nn = new dNode({id:folders[i].folder_id, caption:lang_folder(folders[i].folder_name) + '<font style=color:red>&nbsp(</font><span id="dftree_'+folders[i].folder_id+'_unseen" style=color:red>'+folders[i].folder_unseen+'</span><font style=color:red>)</font>', onClick:"change_folder('"+folders[i].folder_id+"','"+folders[i].folder_name+"')", plusSign:folders[i].folder_hasChildren});
+
+                                if( folders[i].folder_name.toLowerCase() == 'inbox' )
+                                        Element('new_m').innerHTML = '<font style="color:red">' + folders[i].folder_unseen + '</font>';
+                        }
+                        else
+                            var nn = new dNode({id:folders[i].folder_id, caption:lang_folder(folders[i].folder_name), onClick:"change_folder('"+folders[i].folder_id+"','"+folders[i].folder_name+"')", plusSign:folders[i].folder_hasChildren});
+
+                        if (folders[i].folder_parent == '')
+                                folders[i].folder_parent = 'root';
+                        else if (folders[i].folder_parent == 'user')
+                        {
+
+                            if (!tree_folders.getNodeById('user'))
+                            {
+                                tmpFolderId = folders[i].folder_id.split(cyrus_delimiter).pop();
+                                if (tmpFolderId != folders[i].folder_name)
+                                {
+                                        translatedFolders.add(tmpFolderId, folders[i].folder_name);
+                                }
+                                var n_root_shared_folders = new dNode({id:'user', caption:get_lang("Shared folders"), plusSign:true});
+                                tree_folders.add(n_root_shared_folders,'root');
+                            }
+                        }
+                        tree_folders.add(nn,folders[i].folder_parent);
+                    }
+		}
+
+       var handlerChannel = function(data)
+       {
+    	   
+                if ( data == null || typeof(data) == 'string')
+                {    
+                	return false;
+                }
+
+                var nodeParent  = document.getElementById('content_folders');
+                var treeRss     = new dFTree({name: 'treeRss'});
+                var root_rss    = new dNode({id:'news_root', caption: get_lang("News")});
+                    
+                treeRss.add(root_rss,'anything');
+
+                for( i=0; i < data.length; i++ )
+                {
+                    var nodeNews = new dNode(
+                    {
+                            id: "NEWS/"+data[i].name,
+                            caption: data[i].name,
+                            onClick: "open_rss('"+data[i].rss_url+"')",
+                            plusSign: 0
+                     });
+                     treeRss.add(nodeNews,"news_root");
+                }
+                    
+                treeRss.draw( nodeParent );
+                    
+                with ( document.getElementById('lnews_roottreeRss') )
+                {
+                     style.backgroundImage   = "url(templates/"+template+"/images/menu/rss.png)";
+                     style.marginLeft        = "2px";
+                }
+
+                if( nodeParent.firstChild.id != ("dftree_" + treeRss.name ) )
+                {
+                     var _folder     = Element(nodeParent.firstChild.id);
+                     var _rssNews    = Element("dftree_" + treeRss.name );
+                        
+                     nodeParent.insertBefore( _rssNews, _folder );
+                }
+                    
+	   }
+       
+       if( eval(enabledReadRSS ) == true )
+       {	
+    	   setTimeout(function()
+    	   {
+    	     cExecute('$this.rss.getChannels',handlerChannel);
+    	   }, 2000);
+       }
+       
+		/**
+		* Pastas locais
+		*/
+		if (preferences.use_local_messages==1 || expresso_offline) {
+			if (!window.google || !google.gears) {
+				if (!expresso_local_messages.installGears())
+					preferences.use_local_messages=0;
+			}
+			else{
+				if (!window.google || !google.gears) {
+				temp = confirm(get_lang("To use local messages you have to install google gears. Would you like to be redirected to gears installation page?"));
+				if (temp) {
+					location.href = "http://gears.google.com/?action=install&message="+
+					"Para utilizar o recurso de mensagens locais, instale o google gears&return=" +
+					document.location.href;
+				}
+				else {
+					preferences.use_local_messages=0;
+				}
+			}
+			else{
+				if (expresso_offline)
+					tree_folders = new dFTree({
+						name: 'tree_folders'
+					});
+				var root_local = new dNode({
+					id: "local_root",
+					caption: get_lang('local folders')
+				});
+				tree_folders.add(root_local, "root"); //coloca root local
+				var local_folders = expresso_local_messages.list_local_folders();
+				for (var i in local_folders) { //Coloca as pastas locais.
+					var node_root = "local_root";
+					var new_caption = local_folders[i][0];
+					if (local_folders[i][0].indexOf("/") != "-1") {
+						final_pos = local_folders[i][0].lastIndexOf("/");
+						node_root = "local_" + local_folders[i][0].substr(0, final_pos);
+						new_caption = local_folders[i][0].substr(final_pos + 1);
+					}
+					if (local_folders[i][1] > 0)
+						var nodeLocal = new dNode({
+							id: "local_" + local_folders[i][0],
+							caption: lang_folder(new_caption) + '<font style=color:red>&nbsp(</font><span id="local_unseen" style=color:red>' + local_folders[i][1] + '</span><font style=color:red>)</font>',
+							onClick: "change_folder('local_" + local_folders[i][0] + "','" + new_caption + "')",
+							plusSign: local_folders[i][2]
+						});
+					else
+						var nodeLocal = new dNode({
+							id: "local_" + local_folders[i][0],
+							caption: lang_folder(new_caption),
+							onClick: "change_folder('local_" + local_folders[i][0] + "','" + new_caption + "')",
+							plusSign: local_folders[i][2]
+						});
+						tree_folders.add(nodeLocal, node_root);
+					}
+				}
+			}
+		}
+
+		tree_folders.draw(Element('content_folders'));
+		if (!expresso_offline) {
+			n_root.changeState();
+			tree_folders.getNodeById('INBOX')._select();
+		}
+		else {
+			root_local.changeState();
+			tree_folders.getNodeById('local_Inbox')._select();
+		}
+
+		var trash_span=document.getElementById('lINBOX/'+trashfolder+'tree_folders');
+		var draft_span=document.getElementById('lINBOX/'+draftsfolder+'tree_folders');
+		var sent_span=document.getElementById('l'+this.preferences.save_in_folder+'tree_folders');
+		var sent_span_default=document.getElementById('lINBOX/'+sentfolder+'tree_folders');
+		var spam_span=document.getElementById('lINBOX/'+spamfolder+'tree_folders');
+		//local folders
+		var sent_local_conf = this.preferences.save_in_folder.replace("INBOX/","local_");
+		var sent_local_conf_span=document.getElementById('l'+sent_local_conf+'tree_folders');
+		var trash_local_span=document.getElementById('llocal_'+trashfolder+'tree_folders');
+		var draft_local_span=document.getElementById('llocal_'+draftsfolder+'tree_folders');
+		var sent_span_default=document.getElementById('llocal_'+sentfolder+'tree_folders');
+
+
+		if (trash_span)
+			trash_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_trash.png)";
+
+		if (draft_span)
+			draft_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_draft.png)"
+
+		if (sent_span)
+			sent_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_sent.png)";
+		if (spam_span)
+			spam_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_spam.png)";
+
+		if (sent_span_default)
+			sent_span_default.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_sent.png)";
+		//Local folders
+
+		if (sent_local_conf_span)
+			sent_local_conf_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_sent.png)";
+		if (trash_local_span)
+			trash_local_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_trash.png)";
+		if (draft_local_span)
+			draft_local_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_draft.png)"
+		if (sent_span_default)
+			sent_span_default.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_sent.png)";
+
+
+		draw_paging(Element('tot_m').innerHTML);
+		if(document.getElementById("nINBOX/"+trashfolder+"tree_folders"))
+		{
+			var trash = document.createElement("SPAN");
+			trash.id = 'empty_trash';
+			trash.className = 'clean_folder';
+			trash.style.cursor = 'pointer';
+			trash.onclick = function () {empty_trash_imap();};
+			trash.innerHTML = "["+get_lang("Clean")+"]";
+			trash.title=get_lang("Empty trash");
+			trash.onmouseover = function() {trash.style.color="red";};
+			trash.onmouseout= function() {trash.style.color="#666666";};
+			document.getElementById("nINBOX/"+trashfolder+"tree_folders").appendChild(trash);
+		}
+		if(document.getElementById("nINBOX/"+spamfolder+"tree_folders"))
+		{
+						var spam = document.createElement("SPAN");
+						spam.id = 'empty_spam';
+						spam.className = 'clean_folder';
+						spam.style.cursor = 'pointer';
+						spam.style.padding = '0 0 0 6px';
+						spam.onclick = function () {empty_spam_imap();};
+						spam.innerHTML = "["+get_lang("Clean")+"]";
+						spam.title=get_lang("Empty Spam Folder");
+						spam.onmouseover = function() {spam.style.color="red";};
+						spam.onmouseout= function() {spam.style.color="#666666";};
+						document.getElementById("nINBOX/"+spamfolder+"tree_folders").appendChild(spam);
+			   }
+
+
+		if(!expresso_offline)
+			var display_unseen_in_mailbox = tree_folders.getNodeById( 'root' );
+		else
+			var display_unseen_in_mailbox = tree_folders.getNodeById( 'local_root' );
+		display_unseen_in_mailbox.alter({caption:get_lang("My Folders")});
+		display_unseen_in_mailbox._refresh();
+
+		var display_unseen_in_shared_folders = tree_folders.getNodeById( 'user' );
+		if ( display_unseen_in_shared_folders )
+		{
+			if ( unseen_in_shared_folders )
+				display_unseen_in_shared_folders.alter({caption:'<font style=color:red>[</font><span id="dftree_user_unseen" style="color:red">' + unseen_in_shared_folders +'</span><font style=color:red>]</font> ' + get_lang("Shared folders")});
+			else
+				display_unseen_in_shared_folders.alter({caption:get_lang("Shared folders")});
+			display_unseen_in_shared_folders._refresh();
+		}
+	}
+
+	if (!expresso_offline) {
+		var folder_create = "";
+		var nm1 = "";
+		if(tree_folders._folderPr.length > 0){
+			folder_create = tree_folders._folderPr.join(';');
+		}
+		if(folder_create != ""){
+			if(confirm(get_lang("There are folders with invalid format. If you want to fix now, click on button OK."))){
+				var handler_correct_folders = function(data){
+					//Timeout to release HTTPRequest , loadScript and update tree folders.
+					if(data){
+						write_msg(get_lang('The folders were fixed with success.'));
+						setTimeout("connector.loadScript('TreeShow');ttreeBox.update_folder();",500);
+					}
+				}
+				cExecute("$this.imap_functions.create_extra_mailbox",handler_correct_folders,"nw_folders="+folder_create);
+			}
+			else{
+				write_msg(get_lang('Warning: The folders with invalid format will be unavailable.'));
+			}
+		}
+	}
+
+}
+
+function draw_tree_local_folders() {
+	/**
+	 * Pastas locais
+	 */
+	if(preferences.use_local_messages==1 || expresso_offline) {
+		var local_folders = expresso_local_messages.list_local_folders();
+		var has_changes = false;
+		for (var i in local_folders) { //Coloca as pastas locais.
+
+			var new_caption = local_folders[i][0];
+			if(local_folders[i][0].indexOf("/")!="-1") {
+				final_pos = local_folders[i][0].lastIndexOf("/");
+				new_caption = local_folders[i][0].substr(final_pos+1);
+			}
+
+			var folder_unseen = Element('dftree_local_'+local_folders[i][0]+'_unseen');
+
+			if ((folder_unseen) && (local_folders[i][1] > 0))
+			{
+				folder_unseen.innerHTML = local_folders[i][1];
+				has_changes = true;
+			}
+			else if (local_folders[i][1] > 0)
+			{
+				tree_folders.getNodeById("local_"+local_folders[i][0]).alter({caption:lang_folder(new_caption) + '<font style=color:red>&nbsp(</font><span id="dftree_local_'+local_folders[i][0]+'_unseen" style=color:red>'+local_folders[i][1]+'</span><font style=color:red>)</font>'});
+				tree_folders.getNodeById("local_"+local_folders[i][0])._refresh();
+				has_changes = true;
+			}
+			else if (local_folders[i][1] <= 0)
+			{
+				tree_folders.getNodeById("local_"+local_folders[i][0]).alter({caption:lang_folder(new_caption)});
+				tree_folders.getNodeById("local_"+local_folders[i][0])._refresh();
+				has_changes = true;
+			}
+
+			if("local_"+local_folders[i][0] == get_current_folder()){
+				var old_new_m = isNaN(parseInt(Element('new_m').innerHTML)) ? parseInt(Element('new_m').firstChild.innerHTML) : parseInt(Element('new_m').innerHTML);
+				if(!isNaN(old_new_m) && old_new_m < local_folders[i][1]){
+					Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) + (parseInt(local_folders[i][1])-old_new_m);
+				}
+				Element('new_m').innerHTML = local_folders[i][1] ? '<font color="RED">'+local_folders[i][1]+'</font>' : 0;
+				draw_paging(Element('tot_m').innerHTML);
+				has_changes = true;
+			}
+		}
+		if(has_changes)
+			tree_folders.getNodeById("local_root").open();
+
+	}
+}
+
+function update_menu(data){
+		/*
+		 * @AUTHOR Rodrigo Souza dos Santos
+		 * @DATE 2008/09/15
+		 * @BRIEF When occurs a error in imap server show the message that is in file "error.html".
+		 */
+		if ( data && data.imap_error )
+		{
+			if(preferences.use_local_messages==1 && expresso_local_messages.is_offline_installed){
+				conf = confirm(get_lang("The expresso imap server is currently down, expresso noticed you have offline mail module installed, would you like to use it?"));
+				if(conf) {
+					window.onresize = function() {
+						var target = document.getElementById('divAppbox');
+						target.style.height= document.body.clientHeight - 83;
+					}
+					var target = document.getElementById('divAppbox');
+					document.getElementById("divAppboxHeader").innerHTML="";
+					target.style.height= document.body.clientHeight - 83;
+					expresso_local_messages.set_as_logged(account_id,0,true);
+					target.innerHTML = "<iframe src='offline.php?inside=1' width='100%' height='100%' frameBorder='0'></iframe>";
+					return false;
+				}
+			}
+			connector.newRequest('error.html', 'templates/'+template+'/error.html', 'GET',
+				function(data)
+				{
+					var target = document.getElementById('divAppbox');
+					if ( target )
+						target.innerHTML = data;
+				}
+			);
+			return false;
+		}
+
+		draw_tree_folders(data);
+		if(data) {
+			build_quota(data);
+			var f_unseen = Element('dftree_'+current_folder+'_unseen');
+			if(f_unseen && f_unseen.innerHTML)
+				Element('new_m').innerHTML = '<font face="Verdana" size="1" color="RED">'+f_unseen.innerHTML+'</font>';
+			else
+			{
+				if( parseInt(Element('new_m').innerHTML) == 0 )
+					Element('new_m').innerHTML = 0;
+			}
+			folders = data;
+		}
+}
+
+var handler_draw_box = function(data){
+	draw_box(data, 'INBOX', true);
+	//alternate_border(0);
+}
+
+// Action on change folders.
+function change_folder(folder, folder_name){
+	if (openTab.imapBox[0] != folder)
+	{
+		current_folder = folder;
+		var handler_draw_box = function(data)
+		{
+			if(!verify_session(data))
+				return;
+			alternate_border(0);
+			Element("border_id_0").innerHTML = "&nbsp;" + lang_folder(folder_name) + '&nbsp;<font face="Verdana" size="1" color="#505050">[<span id="new_m">&nbsp;</span> / <span id="tot_m"></span>]</font>';
+			draw_box(data, folder, true);
+			draw_paging(data.num_msgs);
+			Element("tot_m").innerHTML = data.num_msgs;
+			update_menu();
+			return true;
+		}
+		proxy_mensagens.messages_list(current_folder,1,preferences.max_email_per_page,sort_box_type,search_box_type,sort_box_reverse,preferences.preview_msg_subject,preferences.preview_msg_tip,handler_draw_box);
+	}
+	else
+		alternate_border(0);
+}
+
+function open_folder(folder, folder_name){
+	if (current_folder!= folder) {
+		current_folder = folder;
+		var handler_draw_box = function(data){
+			if(!verify_session(data))
+				return false;
+			numBox++;
+			create_border(folder_name,numBox.toString());
+			draw_box(data, current_folder, false);
+			alternate_border(numBox);
+			return true;
+		}
+		cExecute ("$this.imap_functions.get_range_msgs2&folder="+current_folder+"&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type="+sort_box_type+ "&search_box_type="+ search_box_type +"&sort_box_reverse="+sort_box_reverse+"", handler_draw_box);
+	}
+	else
+		alternate_border(numBox);
+	return true;
+}
+
+var lastPage = 1;
+var numPages = 5;
+var last_folder = 'INBOX';
+function draw_paging(num_msgs){
+	num_msgs = parseInt(num_msgs);
+	total_pages = 1;
+
+	if(last_folder != current_folder){
+		lastPage = 1;
+		current_page = 1;
+		last_folder = current_folder;
+  	}
+
+	if(num_msgs > parseInt(preferences.max_email_per_page)) {
+		total_pages = parseInt(num_msgs/preferences.max_email_per_page);
+		if((num_msgs/preferences.max_email_per_page) > total_pages)
+			total_pages++;
+	}
+
+	if(total_pages == 1) {
+		if(span_paging = document.getElementById("span_paging")) {
+			span_paging.parentNode.removeChild(span_paging);
+		}
+		return;
+	}
+  	span_paging = document.getElementById("span_paging");
+	if(!span_paging){
+		span_paging = document.createElement("DIV");
+		span_paging.id = "span_paging";
+		span_paging.className = "boxHeaderText";
+		span_paging.align="right";
+		document.getElementById("div_menu_c3").appendChild(span_paging);
+	}
+	span_paging.style.width="100%";
+  	span_paging.innerHTML="";
+  	msg_range_begin = 1;
+	msg_range_end = preferences.max_email_per_page;
+  	if(current_page != 1) {
+	  	lnk_page = document.createElement("A");
+		lnk_page.setAttribute("href", "javascript:current_page=1;kill_current_box(); draw_paging("+num_msgs+"); proxy_mensagens.messages_list(get_current_folder(),"+msg_range_begin+","+msg_range_end+",'"+sort_box_type+"','"+search_box_type+"',"+sort_box_reverse+","+preferences.preview_msg_subject+","+preferences.preview_msg_tip+",function handler(data){alternate_border(0); draw_box(data, get_current_folder());});");
+  	}
+  	else {
+  	 	lnk_page = document.createElement("SPAN");
+  	}
+  	span_paging.appendChild(lnk_page);
+
+  	lnk_page.innerHTML = "&lt;&lt;";
+	lnk_page.title = get_lang("First");
+  	span_paging.innerHTML += "&nbsp;";
+
+  	if(current_page == lastPage + numPages)
+  		lastPage = current_page - 1;
+  	else if((lastPage != 1 && lastPage == current_page) || current_page == total_pages)
+  		lastPage = current_page - (numPages - 1);
+  	else if(current_page == 1)
+  	 	lastPage = 1;
+
+	if(lastPage < 1)
+		lastPage = 1;
+	else if(lastPage > 1 && (lastPage > (total_pages -(numPages - 1))))
+		lastPage = total_pages -(numPages - 1);
+
+	var	hasMarked = false;
+
+  	for(i = lastPage; i <= total_pages; i++) {
+
+  		if(current_page == i || (i == total_pages && !hasMarked)) {
+  			lnk_page = document.createElement("SPAN");
+  			span_paging.appendChild(lnk_page);
+  			lnk_page.innerHTML = "&nbsp;<b>"+i+"</b>&nbsp;";
+  			hasMarked = true;
+  			continue;
+  		}
+  		else{
+  			lnk_page = document.createElement("A");
+  			span_paging.appendChild(lnk_page);
+  			msg_range_begin = ((i*preferences.max_email_per_page)-(preferences.max_email_per_page-1));
+			msg_range_end = (i*preferences.max_email_per_page);
+			lnk_page.setAttribute("href", "javascript:current_page="+i+";kill_current_box(); draw_paging("+num_msgs+"); proxy_mensagens.messages_list(get_current_folder(),"+msg_range_begin+","+msg_range_end+",'"+sort_box_type+"','"+search_box_type+"',"+sort_box_reverse+","+preferences.preview_msg_subject+","+preferences.preview_msg_tip+",function handler(data){alternate_border(0); draw_box(data, get_current_folder());});");
+  		}
+  		lnk_page.innerHTML = "&nbsp;...&nbsp;";
+  		if(i == (lastPage + numPages))
+  				break;
+  		else if(lastPage == 1 || i != lastPage)
+  			lnk_page.innerHTML = "&nbsp;"+i+"&nbsp;";
+  		span_paging.innerHTML += "&nbsp;";
+  	}
+
+ 	if(current_page != total_pages) {
+  		lnk_page = document.createElement("A");
+  		msg_range_begin = ((total_pages*preferences.max_email_per_page)-(preferences.max_email_per_page-1));
+		msg_range_end = (total_pages*preferences.max_email_per_page);
+		lnk_page.setAttribute("href", "javascript:current_page="+total_pages+";kill_current_box(); draw_paging("+num_msgs+"); proxy_mensagens.messages_list(get_current_folder(),"+msg_range_begin+","+msg_range_end+",'"+sort_box_type+"','"+search_box_type+"',"+sort_box_reverse+","+preferences.preview_msg_subject+","+preferences.preview_msg_tip+",function handler(data){alternate_border(0); draw_box(data, get_current_folder());});");
+	}
+	else {
+		lnk_page = document.createElement("SPAN");
+	}
+  	span_paging.innerHTML += "&nbsp;";
+  	span_paging.appendChild(lnk_page);
+
+	lnk_page.title = get_lang("Last");
+  	lnk_page.innerHTML = "&gt;&gt;";
+}
+
+
+// Draw the inbox and another folders
+function draw_box(headers_msgs, msg_folder, alternate){
+	
+	/* 
+	 * When the paging response is not in the correct folder you need to change folder
+	 * This occurs when the Ajax response is not fast enough and the user click in outher 
+	 * folder before finishing the Ajax request
+	 */
+	if (msg_folder != headers_msgs['folder']) { 
+		
+		if (headers_msgs['folder']) {
+			array_folder = headers_msgs['folder'].split('/');
+			
+			if (array_folder.length > 1) {
+				name_folder = array_folder[1];
+			}
+			else {
+				name_folder = headers_msgs['folder'];
+			}
+			current_folder = headers_msgs['folder'];
+			Element("border_id_0").innerHTML = "&nbsp;" + lang_folder(name_folder) + '&nbsp;<font face="Verdana" size="1" color="#505050">[<span id="new_m">&nbsp;</span> / <span id="tot_m"></span>]</font>';
+
+			Element('new_m').innerHTML = headers_msgs['tot_unseen'] ? '<font color="RED">'+headers_msgs['tot_unseen']+'</font>' : 0;
+			Element("tot_m").innerHTML = headers_msgs['num_msgs'];
+
+			tree_folders.getNodeById(headers_msgs['folder'])._select();
+		}
+	}
+	/* --- */
+	
+	if (alternate)
+		kill_current_box();
+
+	if(is_ie)
+		document.getElementById("border_table").width = "99.5%";
+
+	
+	openTab.content_id[numBox] = document.getElementById("content_id_"+numBox);
+	openTab.content_id[numBox].innerHTML = "";
+	openTab.imapBox[numBox] = msg_folder;
+	openTab.type[numBox] = 0;
+
+	table_message_header_box = document.getElementById("table_message_header_box_"+numBox);
+	if (table_message_header_box == null){
+		var table_element = document.createElement("TABLE");
+		var tbody_element = document.createElement("TBODY");
+		table_element.setAttribute("id", "table_message_header_box_"+numBox);
+		table_element.className = "table_message_header_box";
+
+		tr_element = document.createElement("TR");
+		tr_element.className = "message_header";
+		td_element1 = document.createElement("TD");
+		td_element1.setAttribute("width", "1%");
+		chk_box_element = document.createElement("INPUT");
+		chk_box_element.id  = "chk_box_select_all_messages";
+		chk_box_element.setAttribute("type", "checkbox");
+		chk_box_element.className = "checkbox";
+		chk_box_element.onclick = function(){select_all_messages(this.checked);};
+		chk_box_element.onmouseover = function () {this.title=get_lang('Select all messages.')};
+		chk_box_element.onkeydown = function (e){
+			if (is_ie)
+			{
+				if ((window.event.keyCode) == 46)
+					proxy_mensagens.delete_msgs(get_current_folder(),'selected','null');
+			}
+			else
+			{
+				if ((e.keyCode) == 46)
+					proxy_mensagens.delete_msgs(get_current_folder(),'selected','null');
+			}
+		};
+
+		td_element1.appendChild(chk_box_element);
+
+		td_element2 = document.createElement("TD");
+		td_element2.setAttribute("width", "7%");
+		td_element3 = document.createElement("TD");
+		td_element3.setAttribute("width", "29%");
+		td_element3.onclick = function () {sort_box(search_box_type,'SORTFROM');};
+		td_element3.id = "message_header_SORTFROM_"+numBox;
+		td_element3.align = "left";
+		td_element3.innerHTML = get_lang("Who");
+
+		td_element4 = document.createElement("TD");
+		td_element4.setAttribute("width", "38%");
+		td_element4.onclick = function () {sort_box(search_box_type,'SORTSUBJECT');};
+		td_element4.id = "message_header_SORTSUBJECT_"+numBox;
+		td_element4.align = "left";
+		td_element4.innerHTML = get_lang("Subject");
+
+		td_element5 = document.createElement("TD");
+		td_element5.setAttribute("width", "14%");
+		td_element5.onclick = function () {sort_box(search_box_type,'SORTARRIVAL');};
+		td_element5.id = "message_header_SORTARRIVAL_"+numBox;
+		td_element5.align = "center";
+		td_element5.innerHTML = get_lang("Date");
+		td_element6 = document.createElement("TD");
+		td_element6.setAttribute("width", "14%");
+		td_element6.onclick = function () {sort_box(search_box_type,'SORTSIZE');}
+		td_element6.id = "message_header_SORTSIZE_"+numBox;
+		td_element6.align = "left";
+		td_element6.innerHTML = get_lang("Size");
+
+		tr_element.appendChild(td_element1);
+		tr_element.appendChild(td_element2);
+		var td_element21 = document.createElement("TD");
+		td_element21.innerHTML = "&nbsp;&nbsp;&nbsp;";
+		var td_element22 = document.createElement("TD");
+		td_element22.innerHTML = "&nbsp;&nbsp;&nbsp;";
+		var td_element23 = document.createElement("TD");
+		td_element23.innerHTML = "&nbsp;&nbsp;";
+		tr_element.appendChild(td_element21);
+		tr_element.appendChild(td_element22);
+		tr_element.appendChild(td_element23);
+		tr_element.appendChild(td_element3);
+		tr_element.appendChild(td_element4);
+		tr_element.appendChild(td_element5);