AppendMessage Method

Uploads a message to the specified mailbox on the server.

Messages can be uploaded from files (Options parameter set to 1) or from strings (Options=0). To load message from Message object, use Options=0 and pass Message.RawBody property as a value of Message parameter.

To get the UID value assigned to the message in the destination folder, you can use UIDPlusResult property.

blnResult = ObjectName.AppendMessage(MailboxName, Message, [Date], [Flags], [Options])  
MailboxName As String Name of the mailbox to upload message to  
Message Message source string. If Options=1, filename of the file containing message source.  
Date As String (optional) If omitted, current date and time will be used. If specified, sets date of the message. Note that this is the date when the message was received by the server (which corresponds to Envelope.Date value), not the date when the message was created (which corresponds to Date header in the e-mail and Envelope.RFC822Date value).

Use the following format for this value: 01-Jun-2004 15:52:30 -0500

Flags As Variant (optional) Defaults to empty (no flags). Can be either a string like "\Answered \Seen $Starred" (allows for non-standard flags if supported by the server) or a number which is any combination of the following:
  • 1 - Answered
  • 2 - Deleted
  • 4 - Draft
  • 8 - Flagged
  • 16 - Recent
  • 32 - Seen
Options As Long (optional) Defaults to zero. If Options=1, Message parameter points to filename of the file containing message source.  
Return value As Boolean True if successful, False if error has occurred  

Usage example:

Dim Mailer
'Using visual basic to create object
Set Mailer = CreateObject("MailBee.IMAP4")
'Using ASP to create object
'Set Mailer = Server.CreateObject("MailBee.IMAP4")
'In ASP use Response.Write instead of MsgBox

Mailer.EnableLogging = True ' Logging helps to discover any problems
Mailer.LogFilePath = "C:\Temp\imap4_log.txt"

Mailer.LicenseKey = "put your license key here"
If Mailer.Connect("", 143, "MyName", "MyPassword") Then

  ' Upload message from mail.eml file keeping defaults for datetime and flags
  If Mailer.AppendMessage("Inbox", "C:\mail.eml", , , 1) Then
    MsgBox "Message uploaded successfully"
  End If

  MsgBox Mailer.ErrDesc
End If

See Also:

Message.RawBody Property

Copyright © 2002-2022, AfterLogic Corporation. All rights reserved.