MonkeybreadSoftware Posted June 19 Posted June 19 When you build a mail solution using our CURL functions in MBS FileMaker Plugin, you may use sample code to do an IMAP upload. Commonly you use this to upload an email to the Sent folder when you sent it via SMTP. New in version 15.2 is the CURL.SetOptionUploadFlags function to pass the flags for uploads. In older CURL versions there was a default to set seen flag, but now you can and shouuld control it. For example we can use this to set the seen flag for an email, when we upload it to the sent folder, so it doesn't appear as a new email. Or you can set the Flagged flag value to mark the email as flagged. Here is the list of the flags: Name Value Description Answered 1 Sets the Answered flag for IMAP uploads Deleted 2 Sets the Deleted flag for IMAP uploads Draft 4 Sets the Draft flag for IMAP uploads Flagged 8 Sets the Flagged flag for IMAP uploads Seen 16 Sets the Seen flag for IMAP uploads You combine flags with addition, e.g. an answered and seen email has 16 + 1 = 17 as flag. And here is a sample script to upload an email: # Upload Email to Sent folder in file IMAP Email Upload Set Variable [ $curl ; Value: MBS("CURL.New") ] # Set URL with name of the mailbox included: Set Variable [ $result ; Value: MBS("CURL.SetOptionURL"; $curl; CURL Test::URL & "/INBOX.Sent") ] # We upload Set Variable [ $result ; Value: MBS("CURL.SetOptionUpload"; $curl; 1) ] # Pass the email to sent with CRLF emails Set Variable [ $email ; Value: MBS("Text.ReplaceNewLine"; CURL Test::email; 3) ] Set Variable [ $result ; Value: MBS("CURL.SetInputText"; $curl; $email; "UTF-8") ] # login via username and password Set Variable [ $result ; Value: MBS("CURL.SetOptionPassword"; $curl; CURL Test::Password) ] Set Variable [ $result ; Value: MBS("CURL.SetOptionUserName"; $curl; CURL Test::Name) ] # or if you have a token for gmail or office365 instead of a password // Set Variable [ $r ; Value: MBS("CURL.SetOptionXOAuth2Bearer"; $curl; CURL Test::Password) ] # Maybe use alternative IMAP port? // Set Variable [ $r ; Value: MBS("CURL.SetOptionPort"; $curl; 143) ] # This turns TLS on and requires connection to be encrypted Set Variable [ $r ; Value: MBS("CURL.SetOptionUseSSL"; $curl; 3) ] # force TLS v1.2 Set Variable [ $r ; Value: MBS("CURL.SetOptionSSLVersion"; $curl; 6) ] # This disables certificate verification, so we accept any: Set Variable [ $r ; Value: MBS("CURL.SetOptionSSLVerifyHost"; $curl; 0) ] Set Variable [ $r ; Value: MBS("CURL.SetOptionSSLVerifyPeer"; $curl; 0) ] # Better with certificates if you have some: // Set Variable [ $r ; Value: MBS( "CURL.SetOptionCAInfo"; $curl; "/Library/FileMaker Server/certificates.pem") ] // Set Variable [ $r ; Value: MBS("CURL.SetOptionSSLVerifyHost"; $curl; 2) ] // Set Variable [ $r ; Value: MBS("CURL.SetOptionSSLVerifyPeer"; $curl; 1) ] # set flags for email like deleted, draft, seen and others Set Variable [ $result ; Value: MBS("CURL.SetOptionUploadFlags"; $curl; 16) // seen flag ] # do it! Set Field [ CURL Test::Result ; MBS("CURL.Perform"; $curl) ] # Check result: Set Field [ CURL Test::debug ; MBS("CURL.GetDebugMessages"; $curl) ] Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ] If you have an email solution, you may want to include the new function to make sure the right flags are set. Let us know if you have questions. Please try it with the 15.2 plugin.
Recommended Posts