OW3.$createmimemessage()
Function group | Execute on client | Platform(s) |
---|---|---|
OW3 | NO | All |
Syntax
OW3.$createmimemessage(vFrom,lTo,lCc,lBcc,cSubject,iPriority,lHeaders,vContent) Returns lBinaryData
Description
Creates a raw MIME email message from given input. Returns Binary data. The parameters are as follows (the same as the SMTP Worker's $init() method, minus those for the SMTP connection/credentials):
Parameter | Description |
---|---|
vFrom | The email address of the message sender. Either a character value e.g. user@test.com or a row with 2 columns where column 1 is the email address e.g. user@test.com and column 2 is descriptive text for the sender, typically their name |
lTo | A one or two column list where each row identifies a primary recipient of the message. Column 1 contains the email address e.g. user@test.com and column 2 if present contains descriptive text for the recipient, typically their name |
lCc | Empty if there are no CC recipients, or a one or two column list where each row identifies a carbon copied recipient of the message. Column 1 contains the email address e.g. user@test.com and column 2 if present contains descriptive text for the recipient, typically their name |
lBcc | Empty if there are no BCC recipients, or a single column list where each row contains the email address of a blind carbon copied recipient of the message e.g. user@test.com. Unlike lTo and lCc, lBcc does not allow more than 1 column, as blind carbon copied recipients are not added to the message header and therefore the descriptive text is not required |
cSubject | The subject of the message |
iPriority | A kOW3msgPriority... constant that specifies the priority of the message |
lHeaders | A two-column list where each row is an additional SMTP header to send with the message. Column 1 is the header name e.g. 'X-OriginalArrivalTime' and column 2 is the header value e.g. ’23:02' |
vContent | Message content. Either binary raw content, or a list to be sent as MIME. See the documentation for the MailSplit command to see how a MIME list is structured; however note that the charset in the OW3 MIME list is a kUniType... constant |
Example
When using or testing this function, you may like to use the RESTful API provided by Gmail, which requires you to send raw MIME content. Once you've authorized with the oauth2 worker, you can attach the oauth2 worker to a HTTP worker and send the email message using something like the following:
Do lMimeList.$define(lLevel, lContentType, lContentSubType, lFileName, lCharData, lBinData, lCharSet, lEncoding, lContentDisposition, lBodyPartHeaders)
Do lMimeList.$add(0,'text','plain',,lText,,"utf-8","base64",)
Do lToList.$define("")
Do lToList.$add("user@gmail.com")
Do OW3.$createmimemessage("user@gmail.com", lToList,,,"My test email", kOW3msgPriorityHigh, lHeaders, lMimeList) Returns lBinData
Do OXML.$base64encode(lBinData,lErr) Returns lB64
Do bintobase64(lBinData,kTrue,kFalse) Returns lB64
Do lContentRow.$define()
Do lContentRow.$cols.$add("raw",kCharacter,kSimplechar)
Calculate lContentRow.raw as utf8tochar(lB64)
Do iHTTP.$init("https://gmail.googleapis.com/gmail/v1/users/me/messages/send",kOW3httpMethodPost,,lContentRow) Returns #F
Do iHTTP.$start()