« MBS FileMaker Plugin,… | Home | MBS @ FMTraining.TV »

Upload email to Sent folder via IMAP

As you know you can send emails via the CURL functions in MBS Xojo CURL Plugin. To have your mails show up in sent folder, you need to upload them to the IMAP server. The following snippet does it for Xojo. Key thing is to pass in URL to IMAP Server with name of Mailbox, e.g. "imap://imap.monkeybreadsoftware.de/INBOX.Sent". Than you set the upload option and provide the data to send. Of course you should use SSL, certificate verification and pass in your credentials. So here the Xojo code from the example project:

Sub UploadEmail() // we use here TLS with this login: Const Server = "sslin.df.eu" Const Username = "test@macsw.de" Const Password = "xxx" // we build a test email to upload Dim email As New CURLEmailMBS email.Subject = "Test Email" email.PlainText = "We uploaded this email via MBS Plugin."+EndOfLine+EndOfLine+"Greetings"+EndOfLine email.AddTo "test@test.test", "John Miller" email.SetFrom "test@test.test", "Marc Jones"
Dim curl As New CURLSMBS curl.OptionURL = "imap://"+Server+"/INBOX.Sent" curl.OptionUsername = Username curl.OptionPassword = Password curl.OptionUseSSL = curl.kUseSSLall // payload for upload is the email source code curl.InputData = email.EmailSource curl.OptionUpload = True Dim e As Integer = curl.Perform If e<>0 Then MessageBox "Failed with error code: "+Str(e) + ": "+curl.LasterrorMessage Else MessageBox "Email uploaded!" End If // show log Dim s As String = curl.DebugData If s.Encoding = Nil Then s = DefineEncoding(s, encodings.ISOLatin1) End If s = ReplaceLineEndings(s, EndOfLine) LogField.Text = s // when succesful it should end with "We are completely uploaded and fine" from CURL and then "Append completed" from server. End Sub

Let me know whether this works fine for you.

for FileMaker see other blog post: Upload email to Sent folder via IMAP.

14 04 22 - 13:05