SendMail

The SendMail method queues an electronic mail message for batch delivery with attachment(s) and other options.

Syntax

SendMail(defaultMailServer, _
               fromName, _
               fromAddress, _
               priority, _
               returnReceipt, _
               toAddressList, _
               ccAddressList, _
               bccAddressList, _
               attachmentList, _
               messageSubject, _
               messageText, _
               sendHelo, _
               xheaderList, _
               reserved, _
               reserved2, _
)

NB. Note use of the underbar character for line continuation.

Parameters

defaultMailServer
Specifies the name of a default SMTP mail server.
MX records for the domain name are looked up, and attempts are made to send the email via these mailservers. If these attempts all fail, then defaultMailServer will be used. You can leave defaultMailServer blank, in which case no default mailservers will be used.
The defaultMailServer parameter can be a list of multiple mailserrvers, separated by semicolons or commas, failing over to the next in the list if the previous ones are down or unavailable.
fromName
The informal name of the person sending the email message. Can be empty. An error will result if both fromName and fromAddress are empty.
fromAddress
The email address of the person sending the email message. Can be empty. An error will result if both fromName and fromAddress are empty.
priority
The priority of the message. Can be empty or one of "Highest", "High", "Low", "Lowest".
returnReceipt
If empty does nothing. If it has a value of "Yes" then requests a return receipt from the recipients.
toAddressList
The email address of the person to whom the electronic mail message will be sent. Can be empty. Multiple recipients separated by a comma only. An error will result if toAddressList and ccAddressList and bccAddressList are empty.
ccAddressList
The email address of the person to whom the electronic mail message will be carbon-copied. Can be empty. Multiple recipients separated by a comma only. An error will result if toAddressList and ccAddressList and bccAddressList are empty.
Note that many mailservers will become upset if you try to send emails to recipients outside their domain. So if the ccmaillist contains domains that are not the same as the principal recipient beware!
bccAddressList
The email address of the person to whom the electronic mail message will be blind carbon-copied. Can be empty. Multiple recipients separated by a comma only. An error will result if toAddressList and ccAddressList and bccAddressList are empty.
Note that many mailservers will become upset if you try to send emails to recipients outside their domain. So if the bccmaillist contains domains that are not the same as the principal recipient beware!
attach
The file to be attached. Multiple attachments separated by a comma only. Can be empty.
messageSubject
The subject of the message. Can be empty. An error will result if both messageSubject and messageText are empty.
messageText
The text of the message. Can be empty. An error will result if both messageSubject and messageText are empty.
sendHelo
By default, SendMail looks up the domain name of the sending system and uses this as part of the initial HELO request to the SMTP server. Under Windows NT/2000, this lookup typically returns the machine name eg: WEB_SRV and this this name does not conform to the RFC-821 requirement to supply a canonical fully-qualified domain name. The mail still goes through because the SMTP server is required to accept the message anyway, however some SMTP servers can complain to a log file, and this log file can grow large with heavy use. Use sendHelo to set the canonical fully-qualified domain name to an acceptable value
xheaderList
The xheaderList method adds any X-Header or overrides the Date or Content-Type. A list separated by semicolons only. With this method you can change the character set to ISO-8859-1, change the message's date, or change the Content-Type, among many others. NB It is best not to change the Content-Type if you are sending an attachment.
You can use this to change the date of the email, and other values, eg:
"Date=Mon, 31 Dec 2003 23:59:59 -0700;X-Sender=Steven Joyce"
Note that the "=" and ";" symbols are key.
Or even the Email identifier:d
"X-Mailer=SuperMailMan"

Return Values

Returns an empty string if the message was sent successfully. Otherwise returns a string indicating the error that occurred. Notes

If you are sending a long message and you want to format the lines, use VbCrLf (Chr(13)+Chr(10) ) to insert end-of-lines. Eg

message = "Thanks,  " & vbCrLf & vbCrLf & "it works a treat!"

Example

The following sends an email to customer197@mailer.net, with a carbon-copy to sales@mailer.net and two blind carbon-copies. There are no attachments. Priority is normal and no return receipt is requested.


<% Set mailer = Server.CreateObject("EmailResolver.EmailResolverCtrl.1")
<%

defaultmailServer = "mailer1.mailer.net;mailer2.mailer.net"
fromName = "System Administrator"
fromAddress = "admin@mailer.net"
priority = ""
returnReceipt = ""

toAddressList = "customer197@mailer.net"

ccAddressList = "sales@mailer.net"

bccAddressList = "admin@mailer.net"
bccAddressList = bccAddressList & ","
bccAddressList = bccAddressList & "loggingAccount@mailer.net"

attachmentList = ""
messageSubject = "Welcome on board!"
messageText = "Welcome to mailer.net"
messageText = messageText & Chr(10)
messageText = messageText & "We hope you enjoy our services."
messageText = messageText & Chr(10)

heloName = "TWOTHEMARES"
xheaders = "Date=Mon, 31 Dec 2003 23:59:59 -0700;X-Sender=Steven Joyce"


result = mailer.SendMail(defaultmailServer,      _ 
               fromName,      _ 
               fromAddress,      _ 
               priority,      _ 
               returnReceipt,      _ 
               toAddressList,      _ 
               ccAddressList,      _ 
               bccAddressList,      _ 
               attachmentList,      _ 
               messageSubject,      _ 
               messageText,      _ 
               heloName, _
               xheaders, _
               "", _
               "" _
               ) 
%>
<% If  "" = result Then %>
<P>
Mail has been sent.
<P>
<% Else %>
<P>
Mail was not sent, error message is
<H2>
<%= result %>
</H2>
<P>
<% End If %>


 

Applies To

EmailResolver OCX Component