Xbasic

email_send_gmail Function

Syntax

L email_send_gmail(C gmail_email_address, C gmail_email_password, C to, C from, C subject, C html_body, C text_body [, C cc [, C bcc [, C attachments ]]])

Arguments

gmail_email_addressCharacter

The gmail account.

gmail_email_passwordCharacter

The password for the gmail account

toCharacter

The recipient's e-mail address. This can be a comma delimited list of addresses.

fromCharacter

The sender's e-mail address. If the from parameter is blank (i.e. ""), the gmail_email_address will be used.

subjectCharacter

The message subject

html_bodyCharacter

The message in HTML format. Leave blank to specify the message as plain text using the text_body argument.

text_bodyCharacter

The message in plaintext format. If the html_body property is blank, the text_body will be used instead.

ccCharacter

A comma delimited list of addresses to "CC".

bccCharacter

A comma delimited list of address to "BCC".

attachmentsCharacter

A comma delimited list of attachments.

Returns

ResultLogical

Returns .T. if operations succeeds. Otherwise .F.

Description

Send email using the Gmail SMTP server.

Discussion

The email_send_gmail() function sends an email using Gmail's SMTP server. For example:

Example

dim gmail_email_address as c = "[email protected]"
dim gmail_email_password as c = "my gmail email password"
dim from as c = "[email protected]"
dim to as c = "[email protected]"
dim subject as c = "Demo follow-up"
dim html_body as c =<<%html%
Hello Ms. Meadow,
<br><br>
Thank you for taking the time to evaluate Product Co!
Did you have any questions about yesterday's demo? 
I am here to answer <em>any</em> questions you may have. 
I look forward to hearing from you!
<br><br>

Sincerely,<br>
Jane Doe<br>
<strong>Product Co - <em>We have your solutions!</em></strong>
%html%

dim text_body as c = ""
dim cc as c = ""
dim bcc as c = ""
dim attachments as c = "C:\logos\productCoLogo.png"

dim result as l
result = email_send_gmail(gmail_email_address,gmail_email_password,to,from,subject,html_body,text_body,cc,bcc,attachments)
If your Gmail account is configured to use two-factor authentication, you will need to setup an app-specific password in order to use the email_send_gmail() function. See Sign in using App Passwords on Google's website for more information.

See Also