Home
AddEmail 3.0 User Manual
Contents
1. Name Property ENCOding Property sicsicciccscdssniessscsascceveasescesseapccnsescecccssentssevandsdsendosisensnndedsatcssbdccisenectardsabdsesddsedsdueurseabendsdsencasasenr ContentType Property icsscesccscecsscccseccecsedccees scbecetessccesicsstecvacss cates sche ceteccocesieastecsacueisenis scoecebecccersieasbedesastecenvecctecaiescs Chrarset Property ceana wc cc etc cence ccs coat a ustedes cau clutec lt tcus caus cucuegacus cussauevauesstobus Aaa ENAA aaa AAAA inline Property sccccicccssesssiscvcseessssecsecsssecapesansesencatasssescnesansdetecauesssaosndsansendesauesssdsabesaisapeesaudrasancbesthacsansuvarasasanenandcr enst Contentld Property siosana eana aana aeaa aaaea Ae EDA Kiai aa EA eaaa Aapa A iadaaa AEEA aana Kaia LoadFromMemory Method es A WANNA GONOSS a saseccccctactsessstaceencedesanevsescacssceebusankdeecussnesvanecuteceucasecvacasuuecennasdseuenceuetcnses satuuscucecadssaussanes QVERVICW a E E cetctavensuecdecepeeds ve canccede A E E E A 95 Address Property ciiisean irrien onsnai iesea stacsacctsceesecascqcsectesctced shocsauesecetsecesscasedzesvocedstcesauesecetcecessecsedvestercuneescesste 95 IName miae oli m a aE E AEE E E E A E E E 96 SE oTa nN i Aaa E E TE E A E A A A A 97 6 Ma llEncoding issnin aa AE AEAEE EES SAET 97 7 MallPriOrity sorserion tteceee cece ntne dee cae tite ante eeee enna detente ctetteenteteeetEES 97 8 MailStal s soos ccs s ete cdel accede cecentes io evete ewdestind ebdvceeccbivetes Soabenelowtest
2. errorCode objSmtpMail GetErrorCode messageNumber Dim errorDescription As String errorDescription objSmtpMail GetErrorDescription messageNumber Case AddEmailLib MailStatus MailStatusCanceled End Select Please refer to the Reference section of this manual for detailed description of AddEmail objects methods and properties Included ASP NET samples provide code snapshots for common operations such as sending text e mails and sending HTML e mails Samples AddEmail includes the following ASP NET VB samples SimpleSend Sample Location AddEmail Samples ASP NET 1 x VB SimpleSend AddEmail Samples ASP NET VB SimpleSend SimpleSend sample demonstrates how to send text or HTML e mails synchronously using SimpleSend Him Mail Sample Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 38 2 12 2 12 1 Location AddEmail Samples ASP NET 1 x VB HtmIlMail AddEmail Samples ASP NET VB HtmiMail HtmlMail sample demonstrates how to send HTML e mails synchronously using Send This sample also shows how to set alternative text only body of e mail UnicodeMail Sample Location AddEmail Samples ASP NET 1 x VB UnicodeMail AddEmail Samples ASP NET VB UnicodeMail UnicodeMail sample demonstrates how to create and send e mails that contain Unicode characters Unicode can be used in the body of a message in the subject field and in the names of sende
3. Remarks MessageBody can contain plain text or HTML depending on the value of MessageBodyFormat property Default value of MessageBody property is an empty string The message will have no body if MessageBody property contains an empty string MessageBodyFormat Property MessageBodyFormat property specifies format of main body of e mail message Syntax Visual Basic objMailMessage MessageBodyFormat MailFormatText VBScript objMailMessage MessageBodyFormat 0 MailFormatText C objMailMessage MessageBodyFormat AddEmailLib MailFormat MailFormatText C HRESULT get_MessageBodyFormat MailFormat HRESULT put_MessageBodyFormat MailFormat spMailMessage gt PutMessageBodyFormat AddEmailLib MailFormatText Remarks MessageBodyFormat property indicates format of main body of the message Possible format values are defined in the MailFormat enumeration Default value of MessageBodyFormat property is MailFormatText Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 74 3 2 7 3 2 8 MessageBodyEncoding Property MessageBodyEncoding property specifies encoding of main body of e mail message Syntax Visual Basic objMailMessage MessageBodyEncoding MailEncoding7Bit VBScript objMailMessage MessageBodyEncoding 1 MailEncoding7Bit C objMailMessag
4. 5b Alternatively create and fill MailMessage object and send it synchronously using Send or Copyright c 2004 2010 Traysoft Inc All rights reserved 13 AddEmail 3 0 User Manual asynchronously using SendAsync Create message and setup subject and body Dim objMessage As New AddEmailLib MailMessage objMessage MessageSubject test objMessage MessageBody Test message Setup sender Dim objSender As New AddEmailLib MailAddress objSender Address jsmith myserver com objSender Name John Smith objMessage Sender objSender Setup first recipient Dim objRecipient As AddEmailLib MailAddress Set objRecipient New AddEmailLib MailAddress objRecipient Address jane someserver com objRecipient Name Jane Smith objMessage AddRecipient objRecipient Setup second recipient Set objRecipient New AddEmailLib MailAddress objRecipient Address james someserver com objRecipient Name James Smith objMessage AddRecipient objRecipient Send prepared message synchronously Dim strError As String Dim resultCode As Long resultCode objSmtpMail Send objMessage True strError If resultCode 0 Then E mail was sent successfully Else Send failed strError contains detailed error description End If Alternatively send prepared message asynchronously Dim messageNumber As Long messageNumber obj
5. 3 2 23 ClearCcRecipients Method ClearCcRecipients method clears list of recipients in Cc field of e mail message Syntax Visual Basic Sub ClearCcRecipients Copyright c 2004 2010 Traysoft Inc All rights reserved 87 AddEmail 3 0 User Manual 3 2 24 Example objMailMessage ClearCcRecipients VBScript Sub ClearCcRecipients Example objMailMessage ClearCcRecipients C void ClearCcRecipients Example objMailMessage ClearCcRecipients C HRESULT ClearCcRecipients Example spMailMessage gt ClearCcRecipients Parameters None Return value None Remarks Use ClearCcRecipients method to remove all recipients from Cc field of e mail message Using this method you can clear list of recipients after sending and reuse prepared MailMessage object to send the same message to other recipients ClearBccRecipients Method ClearBccRecipients method clears list of recipients in Bcc field of e mail message Syntax Visual Basic Sub ClearBccRecipients Example objMailMessage ClearBccRecipients VBScript Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 88 Sub ClearBccRecipients Example objMailMessage ClearBccRecipients C void ClearBccRecipients Example objMailMessage ClearBccRecipients C HRESULT ClearBcc
6. OnStatusChangeHandler Property OnStatusChangeHandler property specifies a handler for the OnStatusChange event Syntax JavaScript smtpMail OnStatusChangeHandler MailOnStatusChange function MailOnStatusChange mailNumber status Remarks Use OnStatusChangeHandler property to set a handler for the OnStatusChange event in script languages such as VBScript or JavaScript OnProgressHandler Property OnProgressHandler property specifies a handler for the OnProgress event Syntax JavaScript smtpMail OnProgressHandler MailOnProgress function MailOnProgress mailNumber bytesSent bytesTotal Copyright c 2004 2010 Traysoft Inc All rights reserved 69 AddEmail 3 0 User Manual 3 2 3 2 1 Remarks Use OnProgressHandler property to set a handler for the OnProgress event in script languages such as VBScript or JavaScript MailMessage Overview MailMessage object represents e mail message and contains all message data sender recipients subject body attachments etc Syntax Visual Basic Dim objMailMessage As New Add EmailLib MailMessage E st objMailMessage MessageSubject VBScript Dim objMailMessage Set objMailMessage CreateOb objMailMessage MessageSubject ject AddEmail MailMessage E st C AddEmailLib MailMessageClass objMailMessage new AddEmailLib MailMessageClass j objMailMess
7. gt PutContentType application pdf Remarks Default value of ContentType property is an empty string If ContentType is an empty string AddEmail tries to read content type from the registry based on file extension of the attachment Charset Property Charset property specifies character set of the attachment Syntax Visual Basic Copyright c 2004 2010 Traysoft Inc All rights reserved 93 AddEmail 3 0 User Manual objMailAttachment Charset iso 8859 1 VBScript objMailAttachment Charset iso 8859 1 C objMailAttachment Charset iso 8859 1 C HRESULT get_Charset BSTR HRESULT put_Charset BSTR spMailAttachment gt PutCharset iso 8859 1 Remarks Charset indicates which character set should be used to display the attachment Default value of Charset property is an empty string Only text attachments should have Charset property set 3 3 7 Inline Property Inline property specifies whether the attachment is inline embedded in the message Syntax Visual Basic objMailAttachment Inline True VBScript objMailAttachment Inline True C objMailAttachment Inline true C HRESULT get_Inline VARIANT_BOOL HRESULT put_Inline VARIANT_BOOL spMailAttachment gt PutInline VARIANT_TRUE Remarks Default value of Inline property is False Se
8. objSmtpMail new AddEmailLib SmtpMailClass 3b If you are sending e mails asynchronously you will need to access the same SmtpMail object on more than one page In this case store an instance of the SmtpMail object in Session collection if Session SmtpMail null objSmtpMail new AddEmailLib SmtpMailClass Session SmtpMail objSmtpMail else objSmtpMail AddEmailLib SmtpMailClass Session SmtpMail 4 Set SMTP server address port username and password objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpPort 25 objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword 5a Send an e mail synchronously using SimpleSend or SimpleSendAttachment string strError int resultCode ob jSmtpMail SimpleSend jsmith myserver com jJane someserver com james someserver com test Test message out strError j Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 34 if resultCode 0 E mail was sent successfully else Send failed strError contains detailed error description 5b Alternatively create and fill MailMessage object and send it synchronously using Send or asynchronously using SendAsync Create message and setup subject and body MailMessageClass objMessage new AddEmailLib MailMessageClass j objMessage MessageSubject test objM
9. WScript Echo Sent successfully else strError objSmtpMail GetLastErrorDescription WScript Echo strError Please refer to the Reference section of this manual for detailed description of AddEmail objects methods and properties Included JScript samples provide code snapshots for common operations such as sending text e mails sending HTML e mails adding attachments to e mails Copyright c 2004 2010 Traysoft Inc All rights reserved 27 AddEmail 3 0 User Manual 2 7 2 2 8 2 8 1 Samples AddEmail includes the following JScript samples SimpleSend Sample Location AddEmail Samples JS SimpleSend js SimpleSend sample demonstrates how to send text or HTML e mails synchronously using SimpleSendScriptable SimpleSendAttachment Sample Location AddEmail Samples JS SimpleSendAttachment js SimpleSendAttachment sample demonstrates how to send text or HTML e mails with attachments synchronously using SimpleSendAttachmentScriptable HimIMail Sample Location AddEmail Samples JS Htm Mail js HtmIiMail sample demonstrates how to send HTML e mails with attachments synchronously using SendScriptable This sample also shows how to set alternative text only body of e mail ImportHtm IWithImages Sample Location AddEmail Samples VBS IimportHtm Withimages ImportHtmlWithImages sample demonstrates how to import HTML file with embedded images using ImportHTML EmbeddedImages Sa
10. cccesecsseeeseseeesseeessenesenseeeeeseeeeeneeneesseeaeaseeseensaeeesseeessaaeneeeseeeenees 27 eea e e E E E A EAE E E E EE E E A A E 29 ASP JSOriPT S issan SS Sa ES Se ON aoa a SS URS en ee oe 30 Using AddEmail in ASP JScript projects ccsecesesseeeseeesseesseeeeseeeeenessneeseeesseeeneneseneeaseesseeenseasaeeaseeseeeseseesseee 30 Samples eeteccsceeescescsed a a aaae anaa codependdd duce cctceuberseces sacs sauereedcedseesstcuaterdacdssaasesnceancezecaseaevece 32 ASP NET CH canem a caa See Oat a aa ccs ta a as decane dea snes ace ae 33 Using AddEmail in ASP NET C projects ccsecsseesseeeeseeseeeeseeesseeeeenseeeeeaeeesseeeneeasseaeaseeseesaenaeseeeasaaseeesseeesnees 33 SaMples E E E E E E E E E E 35 ASP NET VB oenina AERA AANER AER RASAN AAAA EAEE sacetvabacbietes sacccestbancects seccteads 35 Using AddEmail in ASP NET VB projects ccsecsseesseeeeeesseeeeseeesenneseneseeneneeesseesneeassueeaseesseesaeeasseeeaseeeeeesaeeatnee 35 sorea el e E E E E E E E E E E E E E EE 37 Copyright c 2004 2010 Traysoft Inc All rights reserved Contents II 12 Delphi seceet ceed geese tects shy aaa a aaa eaa E eaa Aa A EA eE aa E E aaa 38 Using AddEmail in Delphi projects cccseesesseeseseeeeeenenessneeeesceeeeseneeeseeesessaeesaseneeesseesassaeseaseneneneneesaseneeeages 38 Samples se secesssccevedescboceteneceeseceszeccadss castes cease vessccesecastedendze eccdaescoese
11. Prepared MailAttachment object containing attachment Return value None Remarks Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 84 Use AddAttachment method to add prepared MailAttachment object to the e mail message Application can call AddAttachment method more than once to add more than one attachment to the message 3 2 20 AddHeader Method AddHeader method adds header value to e mail message Syntax Visual Basic Sub AddHeader strHeader As String strValue As String Example objMailMessage AddHeader X Mailer My Email Application 1 0 VBScript Sub AddHeader strHeader strValue Example objMailMessage AddHeader X Mailer My Email Application 1 0 C void AddHeader string strHeader string strValue Example objMailMessage AddHeader X Mailer My Email Application 1 0 C HRESULT AddHeader BSTR strHeader BSTR strValue Example spMailMessage gt AddHeader X Mailer My Email Application 1 0 Parameters strHeader in String strValue in String Return value None Remarks Use AddHeader method to add custom header and its value to the e mail message Most common Copyright c 2004 2010 Traysoft Inc All rights reserved 85 AddEmail 3 0 User Manual 3 2 21 3 2 22 header is X Mailer it contains name of an application that sen
12. Set Sender property to the prepared MailAddress object containing e mail address and optional name of the sender of the message E mail address and name will appear in the From field of the message This property is required and can t be empty ReplyTo Property ReplyTo property specifies e mail address to reply to Syntax Visual Basic Dim objMailAddress As New AddEmailLib MailAddress objMailAddress Address me myisp com objMailMessage ReplyTo objMailAddress VBScript Dim objMailAddress Set objMailAddress CreateObject AddEmail MailAddress objMailAddress Address me myisp com objMailMessage ReplyTo ob jMailAddress C AddEmailLib MailAddressClass objMailAddress new AddEmailLib MailAddressClass j objMailAddress Address me myisp com objMailMessage ReplyTo ob jMailAddress C HRESULT get_ReplyTo IMailAddress HRESULT put_ReplyTo IMailAddress Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 72 3 2 4 3 2 5 AddEmailLib IMailAddressPtr spMailAddress spMailAddress CreateInstance __uuidof AddEmailLib MailAddress spMailAddress gt PutAddress me myisp com spMailMessage gt PutReplyTo spMailAddress Remarks Set ReplyTo property to the prepared MailAddress object containing e mail address and optional name of a person who should receive a reply E mail address
13. 0 WScript Echo Sent successfully else strError ob jSmtpMail GetLastErrorDescription WScript Echo strError Snapshot 2 text email with attachments var objSmtpMail strError numResultCode objSmtpMail new ActiveXObject AddEmail SmtpMail objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword numResultCode objSmtpMail SimpleSendAttachmentScriptable jsmith myserver com jJane someserver com james someserver com test Test message co files docl pdf c files doc2 pdf strError if numResultCode 0 WScript Echo Sent successfully else strError objSmtpMail GetLastErrorDescription WScript Echo strError Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 26 Snapshot 3 HTML message with attachments var objSmtpMail objMailMessage obj ailAttachment objMailAddress strError numResultCode objSmtpMail new ActiveXObject AddEmail SmtpMail objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword objSmtpMail SmtpSSL false Create message and setup subject and body objMailMessage new ActiveXObject Add Email MailMessage objMailMessage MessageBodyFormat 1 H
14. 25 doesn t work please ask your network administrator or internet service provider what port should be used to send e mails 3 1 4 SmtpUsername Property SmtpUsername property specifies username login or account name on the outgoing mail server Syntax Visual Basic objSmtpMail SmtpUsername smithy VBScript objSmtpMail SmtpUsername smithy C objSmtpMail SmtpUsername smithj C HRESULT get_SmtpUsername BSTR HRESULT put_SmtpUsername BSTR spSmtpMail gt PutSmtpUsername Smithj Remarks SmtpUsername property contains empty string by default This property should be set to an empty string if your outgoing mail server doesn t require authentication 3 1 5 SmtpPassword Property SmtpPassword property specifies password on the outgoing mail server Syntax Visual Basic objSmtpMail SmtpPassword pass VBScript objSmtpMail SmtpPassword pass C Copyright c 2004 2010 Traysoft Inc All rights reserved 47 AddEmail 3 0 User Manual 3 1 7 objSmtpMail SmtpPassword pass C HRESULT get_SmtpPassword BSTR HRESULT put_SmtpPassword BSTR spSmtpMail gt PutSmtpPassword pass Remarks SmtpPassword property contains empty string by default This property should be set to an empty string if your outgoing mail server doesn t require authentication SmtpSSL Prop
15. 74 MessageBodyFile property 78 MessageBodyFormat property 73 Messageld property 78 MessagePriority property 77 MessageSubject property 72 MFC 9 N Name property 91 96 O OnProgress event 67 OnProgressHandler property 68 OnStatusChange event 66 OnStatusChangeHandler property 68 Operating Systems 7 Overview 4 P PowerBuilder 41 R Redistributable Code 7 ReplyTimeout property 56 ReplyTo property 71 RequestReadReceipt property 79 6 Secure Connection 47 Secure Password Authentication 47 Send method 56 SendAsync method 58 Sender property 70 SenderHostname property 49 SerialNumber property 54 SimpleSend method 49 SimpleSendAttachment method 51 SimpleSendHiml method 53 SmtpMail 43 SmtpPassword property 46 SmtpPort property 45 SmtpServer property 45 SmtpSPA property 47 SmtpSSL property 47 SmtpUsername property 46 SPA 47 SSL 47 System Requirements 7 VB NET 18 VB NET Samples 19 VB6 12 VB6 Samples 14 VBA 20 VBA Samples 22 VBScript 23 VBScript Samples 24 Version History 8 Copyright c 2004 2010 Traysoft Inc All rights reserved
16. Location AddEmail Samples C 2002 2003 HtmiMail AddEmail Samples C 2005 201 0 Htm Mail HtmlMail sample demonstrates how to send HTML e mails with attachments using Send This sample also shows how to set alternative text only body of e mail ImportHitm WithImages Sample Location AddEmail Samples C 2002 2003 lmportHtm WithImages AddEmail Samples C 2005 201 0 I mportHtm WithImages ImportHtmlWithImages sample demonstrates how to import HTML file with embedded images using ImportHTML EmbeddedImages Sample Location AddEmail Samples C 2002 2003 Embedded images AddEmail Samples C 2005 201 0 Embeddedimages Embeddedimages sample demonstrates how to create and send HTML e mails with embedded images using Send EnterpriseMail Sample Location AddEmail Samples C 2002 2003 EnterpriseMail AddEmail Samples C 2005 201 0 EnterpriseMail EnterpriseMail sample demonstrates features of AddEmail Enterprise version It shows how to queue and send multiple e mails simultaneously using AddEmail multi threading support This sample also shows how to process events from SmtpMail object In addition this sample shows how to send e mails directly to recipients mail servers without using outgoing mail server of your organization or internet provider UnicodeMail Sample Location AddEmail Samples C 2002 2003 UnicodeMail AddEmail Samples C 2005 201 0 UnicodeMail UnicodeMail sample demonstrates how to create and send e mails that c
17. PutConnectAttempts 1 Remarks Default value of ConnectAttempts property is 2 To send an e mail AddEmail connects to the outgoing mail server specified in SmtpServer property If connection could not be established AddEmail will make ConnectAttempts attempts to connect before giving up and reporting connection error If the server is down and does not respond each connect attempt takes 20 30 seconds You might want to set ConnectAttempts to 1 if you are sending e mails directly without using SMTP server in order to speed up sending Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 56 3 1 15 3 1 16 ReplyTimeout Property ReplyTimeout specifies how many seconds AddEmail will wait for a reply from the outgoing mail server before returning timeout error Syntax Visual Basic objSmtpMail ReplyTimeout 20 VBScript objSmtpMail ReplyTimeout 20 C objSmtpMail ReplyTimeout 20 C HRESULT get_ReplyTimeout LONG HRESULT put_ReplyTimeout LONG spSmtpMail gt PutReplyTimeout 20 Remarks Default value of ReplyTimeout property is 30 To send an e mail AddEmail sends SMTP commands to the outgoing mail server specified in SmtpServer property After each sent command AddEmail will wait up to ReplyTimeout seconds for a reply from the server If the server does not respond within specified ReplyTimeout connection to the s
18. Unicode can be used in the body of a message in the subject field and in the names of sender and recipients SendAsync Sample Location AddEmail Samples C SendAsync HtmIMail sample demonstrates how to send HTML e mails with attachments asynchronously using SendAsync This sample also shows how to process events from SmtpMail object VB6 Using AddEmail in VB6 projects To use AddEmail in your Visual Basic 6 project perform the following steps 1 Add a reference to the AddEmail library In VB6 main menu select Project gt References Find and select AddEmail 3 0 Type Library 2 Declare variable that will hold a reference to the SmtpMail object Dim WithEvents objSmtpMail As AddEmailLib SmtpMail 3 Create instance of SmtpMail object in Form_Load or other functions Set objSmtpMail New AddEmailLib SmtpMail 4 Set SMTP server address port username and password objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpPort 25 objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword 5a Send an e mail synchronously using SimpleSend or SimpleSendAttachment Dim strError As String Dim resultCode As Long resultCode objSmtpMail SimpleSend jsmith myserver com jJane someserver com james someserver com test Test message strError If resultCode 0 Then E mail was sent successfully Else Send failed strError contains detailed error description End If
19. and name will be used when recipient replies to the message This property is optional and can be empty If ReplyTo is not set e mail address and name from the Sender property will be used when replying to the message MessageSubject Property MessageSubject property specifies subject of e mail message Syntax Visual Basic objMailMessage MessageSubject test message VBScript objMailMessage MessageSubject test message C objMailMessage MessageSubject test message C HRESULT get_MessageSubject BSTR HRESULT put_MessageSubject BSTR spMailMessage gt PutMessageSubject test message Remarks Default value of MessageSubject property is an empty string The message will have no subject if MessageSubject property contains an empty string MessageBody Property MessageBody property specifies main body of e mail message Syntax Visual Basic objMailMessage MessageBody Testing testing testing VBScript Copyright c 2004 2010 Traysoft Inc All rights reserved 73 AddEmail 3 0 User Manual 3 2 6 objMailMessage MessageBody Testing testing testing C objMailMessage MessageBody Testing testing testing C HRESULT get_MessageBody BSTR HRESULT put_MessageBody BSTR spMailMessage gt PutMessageBody Testing testing testing
20. email was sent successfully or send operation failed To process events from the SmtpMail object you need to add ATL support to your project inherit your class from IDispEventImpl lt gt template declare event handlers create sink map and subscribe to events class CMyClass public IDispEventImpl lt l CMyClass amp AddEmailLib DIID__ISmtpMailEvents amp AddEmailLib LIBID_AddEmailLib 1 0 gt Copyright c 2004 2010 Traysoft Inc All rights reserved 11 AddEmail 3 0 User Manual public SmtpMail events void __stdcall OnStatusChange LONG messageNumber AddEmailLib MailStatus newStatus void __stdcall OnProgress LONG messageNumber LONG bytesSent LONG bytesTotal ATL sink for SmtpMail events BEGIN_SINK_MAP CMyClass SINK_ENTRY_EX 1 AddEmailLib DIID__ISmtpMailEvents 1 OnStatusChange SINK_ENTRY_EX 1 AddEmailLib DIID__ISmtpMailEvents 2 OnProgress END_SINK_MAP Subscribe to events DispEventAdvise m_spSmtpMail Please refer to the Reference section of this manual for detailed description of AddEmail objects methods and properties Included C samples provide code snapshots for common operations such as sending text e mails sending HTML e mails adding attachments to e mails creating HTML e mails with embedded images Samples AddEmail includes the following C samples SimpleSend Sample Location AddEmail S
21. or SimpleSendAttachmentScriptable Dim strError numResultCode numResultCode objSmtpMail SimpleSendScriptable jsmith myserver com jJane someserver com james someserver com test Test message strError If numResultCode 0 Then The email was sent successfully Response Write Sent successfully Else The email was no Response Write strl End If sent strError contains error description rror E 5b Alternatively create and fill MailMessage object and send it synchronously using SendScriptable or asynchronously using SendAsync Dim objMailMessage objMailAttachment objMailAddress strError numResultCode Create message and setup subject and body Set objMailMessage CreateObject AddEmail MailMessage objMailMessage MessageBodyFormat 1 HTML format objMailMessage MessageSubject test objMailMessage MessageBody lt html gt lt body gt lt b gt Testing lt b gt lt body gt lt html gt Add first attachment Set objMailAttachment CreateObject AddEmail MailAttachment objMailAttachment File c files docl pdf objMailMessage AddAttachment objMailAttachment Add second attachment Set objMailAttachment CreateObject AddEmail MailAttachment objMailAttachment File c files doc2 pdf objMailMessage AddAttachment objMailAttachment Setup sender Set objMailAddress CreateObject AddEmail MailAddress objMai
22. text with some non English characters with line length 76 characters or less MailEncodingQuotedPrintable Quoted printable encoding suitable for English or non English ASCII text with any line length Preserves line formatting MailEncodingBase64 Base64 encoding suitable for binary files Unicode text or non English text MailPriority The following table describes possible values of MailPriority enumeration Value Numeric value Description MailPriorityHigh 1 Specifies higher priority urgent message MailPriorityNormal 3 Specifies normal priority message MailPriorityLow 5 Specifies lower priority message MailStatus The following table describes possible values of MailStatus enumeration Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 98 Value Numeric value Description MailStatusQueued 0 Message was added to the queue but AddEmail didn t start sending it yet MailStatusSending i AddEmail is currently sending this message MailStatusSent Message was sent successfully MailStatusFailed AddEmail was unable to send this message MailStatusCanceled A O N Message was canceled using Cancel or CancelAll method Copyright c 2004 2010 Traysoft Inc All rights reserved Index 100 Index A AddAttachment method 83 AddBcc
23. with any number of attachments to multiple recipients using just one method call SimpleSend method also was modified to support text and HTML e mails with multiple recipients Please refer to the SimpleSend and SimpleSendAttachment topics in this manual for more information Improved Unicode support Version 2 0 automatically detects Unicode characters and creates Unicode e mails even if MessageBodyCharset property is not set In addition version 2 0 supports Unicode in the subject or in the body of the message when you use SimpleSend or SimpleSendAttachment Improved SMTP engine for sending e mails directly Enterprise version only SMTP engine in version 2 0 was updated to improve speed and compatibility when sending e mails directly without using SMTP server of your organization or internet provider New SenderHostname property allows to specify fully qualified domain name of the sending computer Please refer to the SenderHostname topic in this manual for more information New methods for obtaining error code and error description GetLastErrorCode and GetLastErrorDescription methods were added in version 2 0 to improve compatibility with programming languages that do not support out parameters e g JavaScript These methods allow to obtain error code and error description of the last synchronous send operation Improved MIME engine New MIME engine in version 2 0 creates e mails that closely resemble e mails created by Outlook reduci
24. xssccesseeeeecdddeccectcetencescoceesse ESAn ses ccacctscceencavcqescuted ceced shoceaucsaceceuces seus caved vteesstcecaussecercecesseareateseeerseuerscusens CH es E E E RAE E A E E Using AddEmail in C projects Samples sissen aroro nerro eaea E aanere S cacees I espeor ar E aeaa a be geteed steecauelucependey cuaveuingvoeesseveauctecevenceyscasestueccerseuceraesete MBN E EA T E A E E TT Using AddEmail in VB NET projects ss ensseneennnsrnnnnennnrnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnmnnn nnmnnn annnm 18 SAMpPles E E E E A E A E T 19 VBA Microsoft Office s ocinmunnsanrnnennn anneanne eed viele AAE EENAA a A 20 Using AddEmail in VBA projects sairis inisa as anera raoir onanan rarae a aenda aade AS cotershucevcedeecesandsvaeteviey Resi 20 Samples rei eaa eraa Ipar a ar aa opre a Eaa a a aae Ere cecencadedvetetecedacardhccsscessevaseadescetevcesiep 22 VBSCHPE ee aa ea aa ct e E eea aa e aa ee ut seutexyanysansansueevdeneceassesseeevieruess 23 Using AddEmail in VBScript projects renean naea e naaraana eare AE aAA eA NAEK aAA an EEKANNA EAEra ESEESE 23 Samples JScript Using AddEmail in JScript projects iiecccscccccccccccsccs cceeccces co ceececccecsctceveccee caves te eseceesceecueectceysncee SENOK EAKA MEESE KANDES 25 Samples _szecizs sescccis ceed shcesiecaseces eaaa ara edere a EAEra saa Aaaa shee ceede decieces tacvce capdaben ie dace RAENT EEan aaa i 27 A a E E E 27 Using AddEmail in ASP VBScript projects
25. AddEmail 3 0 User Manual Copyright c 2004 2010 Traysoft Inc All rights reserved AddEmail 3 0 User Manual Table of Contents Part N Oo oO FWD Part Il 10 11 Introduction 4 Overview ised eel cele elec eee cee ace Peace 4 What s new in version 3 0 5 lt cesscececeteecnechecec cece tettnectecte ne ne denen ce deeeeecuentersneutenerecunecesendecoessaetoeeensts 4 What s new in version 2 0 cccessececeeeeeeeeeeeeeeeenneee seen seeeeeensnee see seeeseenseeeseenseeseeaseeeseenseeeeeenseeneeentes 5 Legal Information erns era ceteee seeeteeereeenassetenee re ener ieee eener 6 System Reg iremeMtS ssania raean cee vat ey ae aae aa aeaea Ea a EA Ka EKE eaan EAEan EREE 7 Redistributable Code sisirin iaoea a aana aeaa aaaea aaa A aaa anaa aAa aa erate 7 Version HIStory scssi e EEEE E E 8 Samples and Tutorials 9 C rHMPECATI cnini aaa aE ER A Ea NA AEEA ARREA 9 Using AddEmail in C PrOjeCiS sicccczcccccecccdecsccicecedeetcccdesaucccecseaccceutescucedtecancesiaasetucecccycuctercevedbecsudeviansesu vecaysucterdeves 9 Samples szecepcscedvoecsdeaceneeseedtecescachgusepecetescht catctsccesgocdtchdteedtbaes che datceoudesteasvedstuceesabeescee dau sccdesteasyacesatercneesnces duduace 11 VBG 00 E E seceteueandetuedsecetoaees decuee sucetoancndetuee E 12 Using AddEmail in VBO Projects iiccc2 sccccccces sects ctcectcectersteernccd ce cencieenceeccceestetataesuccestepeccey ences seeveptedcbecsuccestesecteviees 12 Samples
26. Address As AddEmailLib MailAddress Example Dim objMailAddress As New AddEmailLib MailAddress objMailAddress Address someone someisp com objMailMessage AddBccRecipient objMailAddress VBScript Sub AddBccRecipient objMailAddress Example Dim objMailAddress Set objMailAddress CreateObject AddEmail MailAddress objMailAddress Address someone someisp com objMailMessage AddBccRecipient objMailAddress C void AddBccRecipient AddEmailLib MailAddressClass objMailAddress Example AddEmailLib MailAddressClass objMailAddress new AddEmailLib MailAddressClass j objMailAddress Address someone somesp com objMailMessage AddBccRecipient objMailAddress C HRESULT AddBccRecipient IMailAddress objMailAddress Example AddEmailLib IMailAddressPtr spMailAddress spMailAddress CreateInstance __uuidof AddEmailLib MailAddress spMailAddress gt PutAddress Someone someisp com spMailMessage gt AddBccRecipient spMailAddress Parameters objMailAddress in Prepared MailAddress object containing e mail address and name of the recipient Return value None Remarks Use AddBccRecipient method to add prepared MailAddress object containing e mail address and optional name of the recipient of e mail message E mail address and name will not visible but the message will be sent to Bcc recipients Application can call AddBccRecipie
27. Attachment Add second attachment objMailAttachment new ActiveXObject AddEmail MailAttachment objMailAttachment File c files doc2 pdft objMailMessage AddAttachment objMailAttachment Setup sender objMailAddress new ActiveXObject AddEmail MailAddress objMailAddress Name John Smith objMailAddress Address jsmith myserver com objMailMessage Sender ob jMailAddress Setup first recipient objMailAddress new ActiveXObject AddEmail MailAddress objMailAddress Name Jane Smith objMailAddress Address jane someserver com objMailMessage AddRecipient objMailAddress Setup second recipient objMailAddress new ActiveXObject AddEmail MailAddress objMailAddress Name James Smith objMailAddress Address james someserver com objMailMessage AddRecipient objMailAddress Send prepared message synchronously numResultCode objSmtpMail SendScriptable objMailMessage true strError if numResultCode 0 The email was sent successfully Response Write Sent successfully else Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 32 2 9 2 The email was not sent strError contains error description strError objSmtpMail GetLastErrorDescription Response Write strError Alternatively send prepared messa
28. Code objSmtpMail CREATEOBJECT AddEmail SmtpMail objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword strError numResultCode objSmtpMail SimpleSendAttachment jsmith myserver com jJane someserver com james someserver com test Test message co files docl pdf c files doc2 pdf strError IF numResultCode 0 THEN MESSAGEBOX Sent successfully ELSE MESSAGEBOX strError ENDIF Snapshot 3 HTML message with attachments E PRIVATE objSmtpMail objMailMessage objMailAttachment objMailAddress PRIVATE strError numResultCode objSmtpMail CREATEOBJECT AddEmail SmtpMail objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword Create message and setup subject and body objMailMessage CREATEOBJECT AddEmail MailMessage objMailMessage MessageBodyFormat 1 amp amp HTML format objMailMessage MessageSubject test objMailMessage MessageBody lt html gt lt body gt lt b gt Testing lt b gt lt body gt lt html1 gt Add first attachment objMailAttachment CREATEOBJECT AddEmail MailAttachment objMailAttachment File c files docl pdf objMailMessage AddAttachment objMailAttachment Add secon
29. FC 821 page 34 35 Remarks SimpleSendAttachment can be used to send text or HTML e mails Body of the e mail message should start with lt html gt tag for HTML e mail messages This method supports Unicode in the subject and body of the message as well as in the sender s and recipients names AddEmail will create Unicode e mail UTF 8 encoding if any part of the message contains Unicode characters This method is synchronous it returns after the message was sent or after an error occuried Please Copyright c 2004 2010 Traysoft Inc All rights reserved 53 AddEmail 3 0 User Manual 3 1 12 use it with care because single threaded applications are blocked and can t process user input for the duration of the SimpleSendAttachment call Please refer to SendAsync Method if you want to send messages without blocking your application SimpleSendHtml Method SimpleSendHtml method imports HTML file from disk and sends HTML e mail with embedded images to one or more recipients synchronously Syntax Visual Basic Function SimpleSendHtml strFrom As String strTo As String strSubject As String strHtmlFile As String ByRef strError As String As Long Example Dim strError As String Dim numResultCode As Long numResultCode objSmtpMail SimpleSendHtml My Name lt me myisp com gt Someone lt someone someisp com gt someoneelse someotherisp com test c files email html strError VB
30. GetQueueSize Example numMessages objSmtpMail GetQueueSize C int GetQueueSize Example int numMessages objSmtpMail GetQueueSize C HRESULT GetQueueSize LONG pnumErrorCode Example int numMessages spSmtpMail gt GetQueueSize Parameters None Return value Returns number of messages in AddEmail queue Remarks SendAsync method places a message into a message queue and exits Afer that AddEmail starts sending messages from the queue using background thread s Use GetQueueSize method to get the number of messages queued for sending 3 1 26 OnStatusChange Event OnStatusChange event is fired on every status change for the message that was queued for sending using SendAsync method Copyright c 2004 2010 Traysoft Inc All rights reserved 67 AddEmail 3 0 User Manual 3 1 27 Syntax Visual Basic Sub OnStatusChange numMessageNumber As Long numNewStatus As Long C void OnStatusChange int numMessageNumber int numNewStatus C void __cdecl OnStatusChange LONG numMessageNumber LONG numNewStatus Parameters numMessageNumber in Message number returned from the SendAsync method numNewStatus fin New status of the message one of the values from the MailStatus enumeration Return value None Remarks SendAsync method places a message into a message queue and returns message number which identifies the
31. Professional Workstation or Server Redistributable Code The Redistributable Code is the property of Traysoft Inc and its suppliers and is protected by copyright law and international treaty provisions You are authorized to make and use copies of the Redistributable Code either as part of the application in which you received the Redistributable Code or in conjunction with the application for which its use is intended Except as expressly provided in the End User License Agreement you are not authorized to reproduce and distribute the Redistributable Code Traysoft reserves all rights not expressly granted You may not reverse engineer decompile or disassemble the Redistributable Code except and only to the extent that such activity is expressly Copyright c 2004 2010 Traysoft Inc All rights reserved Introduction 8 permitted by applicable law notwithstanding this limitation THE REDISTRIBUTABLE CODE IS PROVIDED TO YOU AS IS WITHOUT WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND OR FITNESS FOR A PARTICULAR PURPOSE YOU ASSUME THE ENTIRE RISK AS TO THE ACCURACY AND THE USE OF THE REDISTRIBUTABLE CODE TRAYSOFT SHALL NOT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING OUT OF THE USE OF OR INABILITY TO USE THE REDISTRIBUTABLE CODE EVEN IF TRAYSOFT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE Redistributable Code Redistributable Code i
32. Recipient method 81 AddCcRecipient method 80 AddHeader method 84 AddRecipient method 79 Address property 95 AltMessageBody property 75 AltMessageBodyCharset Property 76 AltMessageBodyEncoding Property 76 ASP NET C 33 ASP NET C Samples 35 ASP NET VB NET 35 ASP NET VB NET Samples 37 ASP JScript 30 ASP JScript Samples 32 ASP VBScript 27 ASP VBScript Samples 29 ATL 9 C C 15 C Samples 16 C 9 C Samples 11 Cancel Method 62 CancelAll method 63 Charset property 92 ClearAttachments method 85 ClearBccRecipients method 87 ClearCcRecipients method 86 ClearRecipients method 85 ConnectAttempts property 55 Contentld property 94 ContentType property 92 D Delphi 38 Delphi Samples 39 Development Environment 7 E Encoding property 91 F File property 90 FoxPro 39 G GetErrorCode method 60 GetErrorDescription method 61 GetLastErrorCode method 64 GetLastErrorDescription method 65 GetQueueSize method 66 GetStatus method 59 ImportHTML method 88 Inline property 93 ie JavaScript 25 JavaScript Samples 27 afi Legal Information 6 LoadFromMemory method 94 MailAddress 95 MailAttachment 89 MailEncoding 97 MailFormat 97 MailMessage 69 MailPriority 97 MailStatus 97 MaxThreads property 48 MessageBody property 72 Copyright c 2004 2010 Traysoft Inc All rights reserved 101 AddEmail 3 0 User Manual MessageBodyCharset property 74 MessageBodyEncoding property
33. Recipients Example spMailMessage gt ClearBccRecipients Parameters None Return value None Remarks Use ClearBccRecipients method to remove all recipients from Bcc field of e mail message Using this method you can clear list of recipients after sending and reuse prepared MailMessage object to send the same message to other recipients 3 2 25 ImportHTML Method ImportHTML method imports HTML file with embedded images Syntax Visual Basic Sub ImportHTML strFilename As String Example objMailMessage ImportHTML c files email html VBScript Sub ImportHTML strFilename Example Copyright c 2004 2010 Traysoft Inc All rights reserved 89 AddEmail 3 0 User Manual 3 3 3 3 1 objMailMessage ImportHTML c files email html C void ImportHTML string strFilename Example objMailMessage ImportHTML c files email html C HRESULT ImportHTML BSTR strFilename Example spMailMessage gt ImportHTML c files email html Parameters strFilename in Filename of the HTML file to be imported Return value None Remarks Use ImportHTML method to create HTML e mail with embedded images from a file on disk This method imports specified HTML file adds all images referenced in the HTML as inline attachments modifies HTML as needed and fills out the MessageBody Only images located on disk are added as attachment
34. ResultCode objSmtpMail SimpleSendAttachment jsmith myserver com Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 42 jJane someserver com james someserver com test Test message co files docl pdf c files doc2 pdf Ref strError If numResultCode 0 Then MessageBox AddEmail Sent successfully Else MessageBox AddEmail strError End If Destroy objSmtpMail Snapshot 2 HTML message with attachments OLEObject objSmtpMail objMailMessage objMailAttachment objMailAddress string strError long numResultCode objSmtpMail Create OLEObject If objSmtpMail ConnectToNewObject AddEmail SmtpMail lt 0 Then Destroy objSmtpMail essageBox AddEmail Can t create AddEmail SmtpMail COM object Return End If objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword objMailMessage Create OLEObjec ck FT objMailMessage ConnectToNewObject AddEmail MailMessage objMailMessage MessageBodyFormat 1 objMailMessage MessageSubject test objMailMessage MessageBody lt html gt lt body gt lt b gt Testing lt b gt lt body gt lt html1 gt objMailAttachment Create OLEObject objMailAttachment ConnectToNewObject AddEmail MailAttachment objMailAttachment File c files docl pdf objMailMessage AddAttach
35. SULT get_Address BS HRESULT put_Address BS TR TR i spMailAddress gt PutAddress Ssmithj someisp com Remarks 3 4 3 Name Property Name property specifies name of recipient or sender as it should appear in the e mail Syntax Visual Basic objMailAddress Name John Smith VBScript objMailAddress Name John Smith C objMailAddress Name C John Smith HRESULT get_Name BSTR HRESULT put_Name BSTR spMailAddress gt PutName Remarks If Name property is an empty string only e mail address will be displayed in the e mail message r John Smith Copyright c 2004 2010 Traysoft Inc All rights reserved 97 AddEmail 3 0 User Manual 3 5 3 6 3 7 3 8 MailFormat The following table describes possible values of MailFormat enumeration Value Numeric value Description MailFormatText 0 Specifies text format MailFormatHtml 1 Specifies HTML format MailEncoding The following table describes possible values of MailEncoding enumeration Value Numeric value Description MailEncodingDefault 0 AddEmail will select suitable encoding based on the content MailEncoding7Bit 7 bit encoding suitable for English ASCII text with line length 76 characters or less MailEncoding8Bit 8 bit encoding suitable for mostly English ASCII
36. Script Function SimpleSendHtmlScriptable strFrom strTo strSubject strHtmlFile ByRef strError Example Dim strError Dim numResultCode numResultCode objSmtpMail SimpleSendHtmlScriptable My Name lt me myisp com gt Someone lt someone someisp com gt someoneelse someotherisp com test c files email html strError C int SimpleSendHtml string strFrom string strTo string strSubject string strHtmlFile out string strError Example string strError int numResultCode objSmtpMail SimpleSendHtml My Name lt me myisp com gt Someone lt someone someisp com gt someoneelse someotherisp com test o files email html out strError C HRESULT SimpleSendHtml BSTR strFrom BSTR strTo BSTR strSubject BSTR strHtmlFile BSTR pstrError LONG pnumResultCode Example BSTR bstr int numResultCode spSmtpMail gt SimpleSendHtml My Name lt me myisp com gt Someone lt someone someisp com gt someoneelse someotherisp com test o files email html amp bstr Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 54 3 1 13 _bstr_t strError bstr FALSE Parameters strFrom fin Sender s e mail address You can also specify sender s name followed by the sender s e mail address in angled brackets strTo in List of recipients e mail addresses separated by semicolon You can a
37. SendAttachment My Name lt me myisp com gt Someone lt someone someisp com gt someoneelse someotherisp com test Test message c files docl pdf c files doc2 pdf out strError C HRESULT SimpleSendAttachment BSTR strFrom BSTR strTo BSTR strSubject BSTR strMessage BSTR strAttach BSTR pstrError LONG pnumResultCode Example BSTR bstr int numResultCode spSmtpMail gt SimpleSendAttachment My Name lt me myisp com gt Someone lt someone someisp com gt someoneelse someotherisp com test Test message c files docl pdf c files doc2 pdf amp bstr _bstr_t strError bstr FALSE Parameters strFrom fin Sender s e mail address You can also specify sender s name followed by the sender s e mail address in angled brackets strTo in List of recipients e mail addresses separated by semicolon You can also specify recipient s name followed by the recipient s e mail address in angled brackets strSubject in Subject of the e mail message strMessage in Body of the e mail message strAttach in List of attachments separated by semicolon strError out Contains extended error information if the message failed to be sent empty string otherwise Return value Returns numeric result 0 if the message was sent successfully 1 if connection to the server failed or in case of other Winsock errors gt 0 SMTP error code as defined in R
38. SerialNumber Serial number to activate purchased copy of AddEmail SenderHostname Fully qualified hostname of the computer that sends the e mails ConnectAttempts Number of connect attempts before reporting connection error ReplyTimeout Number of seconds to wait for a response from SMTP server before reporting timeout error OnStatusChangeHandler Handler for the OnStatusChange event OnProgressHandler Handler for the OnProgress event Methods SimpleSend Sends simple text or HTML e mail message synchronously SimpleSendAttachment Sends simple text or HTML e mail message with attachments synchronously SimpleSendHtml Imports HTML file and sends HTML e mail with embedded images synchronously Send Sends e mail message synchronously SendAsync Sends e mail message asynchronously GetStatus Returns status of e mail message GetErrorCode Returns error code of failed e mail message GetErrorDescription Returns error description of failed e mail message Cancel Cancels sending of queued e mail message CancelAll Cancels all queued e mail messages GetLastErrorCode Returns error code of the last synchronous send operation GetLastErrorDescription Returns error description of the last synchronous send operation GetQueueSize Returns number of e mail messages queued for sending Events OnStatusChange Notifies of message status changes OnProg
39. SmtpMail SendAsync objMessage True 6 If the e mail is sent asynchronously your application will need to process events to find out when the email was sent successfully or send operation failed To process events from the SmtpMail object declare event handlers as shown below Private Sub objSmtpMail_OnStatusChange ByVal messageNumber As Long ByVal newStatus As Long Event processing code End Sub Private Sub objSmtpMail_OnProgress ByVal messageNumber As Long ByVal bytesSent As Long ByVal bytesTotal As Long Event processing code End Sub Please refer to the Reference section of this manual for detailed description of AddEmail objects methods and properties Included Visual Basic samples provide code snapshots for common operations such as sending text e mails sending HTML e mails adding attachments to e mails creating HTML e mails with embedded images Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 14 2 2 2 Samples AddEmail includes the following Visual Basic 6 samples SimpleSend Sample Location AddEmail Samples VB6 SimpleSend SimpleSend sample demonstrates how to send text or HTML e mails synchronously using SimpleSend SimpleSendAttachment Sample Location AddEmail Samples VB6 SimpleSendAttachment SimpleSendAttachment sample demonstrates how to send text or HTML e mails with attachments synchronously using SimpleSendAttachment HimIMail Sam
40. TML format objMailMessage MessageSubject test objMailMessage MessageBody lt html gt lt body gt lt b gt Testing lt b gt lt body gt lt html gt Add first attachment objMailAttachment new ActiveXObject AddEmail MailAttachment objMailAttachment File c files docl pdft objMailMessage AddAttachment objMailAttachment Add second attachment objMailAttachment new ActiveXObject AddEmail MailAttachment objMailAttachment File c files doc2 pdt objMailMessage AddAttachment objMailAttachment Setup sender objMailAddress new ActiveXObject Add objMailAddress Name John Smith Email MailAddress objMailAddress Address jsmith myserver com objMailMessag Setup first recipient objMailAddress new ActiveXObject Add objMailAddress Name Jane Smith Sender objMailAddress Email MailAddress objMailAddress Address jane someserver com objMailMessag Setup second recipient objMailAddress new ActiveXObject Add objMailAddress Name James Smith AddRecipient objMailAddress Email MailAddress objMailAddress Address james someserver com objMailMessage AddRecipient objMailAddress Send prepared messag synchronously numResultCode objSmtpMail SendScriptable objMailMessage true strError if numResultCode 0
41. Type Library 2 Add a code that creates SmtpMail object and sends a message using SimpleSend SimpleSendHiml SimpleSendAttachment or Send Please use code snapshots below to get started Snapshot 1 simple text email Dim objSmtpMail As Object strError As String numResultCode As Long Set objSmtpMail CreateObject AddEmail SmtpMail objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword numResultCode objSmtpMail SimpleSend jsmith myserver com jJane someserver com james someserver com test Test message strError If numResultCode 0 Then MsgBox Sent successfully Else MsgBox strError End LE Snapshot 2 text email with attachments Dim objSmtpMail As Object strError As String numResultCode As Long Set objSmtpMail CreateObject AddEmail SmtpMail objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword numResultCode objSmtpMail SimpleSendAttachment jsmith myserver com jJane someserver com james someserver com test Test message co files docl pdf c files doc2 pdf strError If numResultCode 0 Then MsgBox Sent successfully Else MsgBox strError End If Snapshot 3 HTML message with attachments Dim objSmtpMail As Object strError As String numResultCode As Long Set objSmtpMail CreateObject AddEmail SmtpM
42. age ClearAttachments Clears list of attachments ClearRecipients Clears list of recipients in the To field of e mail message ClearCcRecipients Clears list of recipients in the Cc field of e mail message ClearBccRecipients Clears list of recipients in the Bcc field of e mail message ImportHTML Imports HTML file with embedded images Sender Property Sender property specifies sender of e mail message Syntax Visual Basic Dim objMailAddress As New AddEmailLib MailAddress objMailAddress Address me myisp com objMailMessage Sender ob jMailAddress Copyright c 2004 2010 Traysoft Inc All rights reserved 71 AddEmail 3 0 User Manual 3 2 3 VBScript Dim objMailAddress Set objMailAddress CreateObject AddEmail MailAddress objMailAddress Address me myisp com objMailMessage Sender objMailAddress C AddEmailLib MailAddressClass objMailAddress new AddEmailLib MailAddressClass j objMailAddress Address me myisp com objMailMessage Sender objMailAddress C HRESULT get_Sender IMailAddress HRESULT put_Sender IMailAddress AddEmailLib IMailAddressPtr spMailAddress spMailAddress CreateInstance __uuidof AddEmailLib MailAddress spMailAddress gt PutAddress me myisp com spMailMessage gt PutSender spMailAddress Remarks
43. age MessageSubject t st C AddEmailLib IMailMessagePtr spMailMessage spMailMessage CreateInstance __uuidof AddEmailLib MailMessage spMailMessage gt PutMessageSubj Properties ct test Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 70 3 2 2 Sender Sender of e mail message ReplyTo Reply to address MessageSubject Subject of e mail message MessageBody Body of e mail message MessageBodyFormat Format of the body of e mail message MessageBodyEncoding Encoding of the body of e mail message MessageBodyCharset Character set of the body of e mail message AltMessageBody Alternative text only body of e mail message AltMessageBodyEncoding Encoding of the alternative body of e mail message AltMessageBodyCharset Character set of the alternative body of e mail message MessagePriority Priority of e mail message Messageld Id of e mail message MessageBodyFile Filename of the file that contains body of e mail message RequestReadReceipt Request a read receipt for the message Methods AddRecipient Adds recipient to the To field of e mail message AddCcRecipient Adds recipient to the Cc field of e mail message AddBccRecipient Adds recipient to the Bcc field of e mail message AddAttachment Adds attachment to e mail message AddHeader Adds header value to e mail mess
44. ail objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword Create message and setup subject and body Dim objMailMessage As Object Set objMailMessage CreateObject AddEmail MailMessage objMailMessage MessageBodyFormat 1 HTML format objMailMessage MessageSubject test objMailMessage MessageBody lt html gt lt body gt lt b gt Testing lt b gt lt body gt lt html1 gt Add first attachment Dim objMailAttachment As Object Set objMailAttachment CreateObject AddEmail MailAttachment objMailAttachment File c files docl pdf objMailMessage AddAttachment objMailAttachment Add second attachment Set objMailAttachment CreateObject AddEmail MailAttachment objMailAttachment File c files doc2 pdf objMailMessage AddAttachment objMailAttachment Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 22 2 5 2 Setup sender Dim objMailAddress As Object Set objMailAddress CreateObject AddEmail MailAddress objMailAddress Name John Smith objMailAddress Address jsmith myserver com objMailMessage Sender objMailAddress Setup first recipient Set objMailAddress CreateObject AddEmail MailAddress objMailAddress Name Jane Smith objMailAddress Address jane someserver com objMailMessage AddRecipient
45. ail SmtpUsername objSmtpMail SmtpPassword jsmith mypassword Copyright c 2004 2010 Traysoft Inc All rights reserved 31 AddEmail 3 0 User Manual 5a Send an e mail synchronously using SimpleSendScriptable or SimpleSendAttachmentScriptable var strError numResultCode numResultCode objSmtpMail SimpleSendScriptable jsmith myserver com jJane someserver com james someserver com test Test message strError if numResultCode 0 The email was sent successfully Response Write Sent successfully else The email was not sent strError contains error description strError objSmtpMail GetLastErrorDescription Response Write strError 5b Alternatively create and fill MailMessage object and send it synchronously using SendScriptable or asynchronously using SendAsync var objMailMessage objMailAttachment objMailAddress strError numResultCode Create message and setup subject and body objMailMessage new ActiveXObject AddEmail MailMessage objMailMessage MessageBodyFormat 1 HTML format objMailMessage MessageSubject test objMailMessage MessageBody lt html gt lt body gt lt b gt Testing lt b gt lt body gt lt html gt Add first attachment objMailAttachment new ActiveXObject AddEmail MailAttachment objMailAttachment File c files docl pdft objMailMessage AddAttachment objMail
46. amples C SimpleSend SimpleSend sample demonstrates how to send text or HTML e mails using SimpleSend SimpleSendAttachment Sample Location AddEmail Samples C SimpleSendAttachment SimpleSendAttachment sample demonstrates how to send text or HTML e mails with attachments using SimpleSendAttachment Him Mail Sample Location AddEmail Samples C HtmiMail HtmlMail sample demonstrates how to send HTML e mails with attachments using Send This sample also shows how to set alternative text only body of e mail EmbeddedImages Sample Location AddEmail Samples C Embedded images Embeddedimages sample demonstrates how to create and send HTML e mails with embedded images using Send EnterpriseMail Sample Location AddEmail Samples C EnterpriseMail EnterpriseMail sample demonstrates features of AddEmail Enterprise version It shows how to queue and send multiple e mails simultaneously using AddEmail multi threading support This sample also Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 12 2 2 2 2 1 shows how to process events from SmtpMail object In addition this sample shows how to send e mails directly to recipients mail servers without using outgoing mail server of your organization or internet provider UnicodeMail Sample Location AddEmail Samples C UnicodeMail UnicodeMail sample demonstrates how to create and send e mails that contain Unicode characters
47. arset unicode VBScript objMailMessage MessageBodyCharset unicode C Copyright c 2004 2010 Traysoft Inc All rights reserved 75 AddEmail 3 0 User Manual objMailMessage MessageBodyCharset unicode C 3 2 9 HRESULT get_MessageBodyCharset BSTR HRESULT put_MessageBodyCharset BSTR spMailMessage gt PutMessageBodyCharset unicode Remarks MessageBodyCharset indicates which character set should be used to display main body of the message Default value of MessageBodyCharset property is an empty string Most common values of MessageBodyCharset property are us ascii US ASCII iso 8859 1 Western European ISO windows 1252 Western European Windows unicode Unicode internally converted to UTF 8 iso 8859 2 Central European ISO windows 1250 Central European Windows For more information please visit Charsets in Microsoft Internet Explorer AltMessageBody Property AltMessageBody property specifies alternative text only body of e mail message Syntax Visual Basic objMailMessage AltMessageBody Testing testing testing VBScript objMailMessage AltMessageBody Testing testing testing C objMailMessage AltMessageBody Testing testing testing C HRESULT get_AltMessageBody BSTR HRESULT put_AltMessageBody BSTR spMailMessage g
48. ass objMailAddress Address someone somesp com objMailMessage AddRecipient objMailAddress C HRESULT AddRecipient IMailAddress objMailAddress Example AddEmailLib IMailAddressPtr spMailAddress spMailAddress CreateInstance __uuidof AddEmailLib MailAddress spMailAddress gt PutAddress Someone someisp com spMailMessage gt AddRecipient spMailAddress Parameters objMailAddress in Prepared MailAddress object containing e mail address and name of the recipient Return value None Remarks Use AddRecipient method to add prepared MailAddress object containing e mail address and optional name of the recipient of e mail message E mail address and name will appear in the To field of the message Application can call AddRecipient method more than once to have more than one recipient in the To field AddCcRecipient Method AddCcRecipient method adds recipient to the Cc field of e mail message Syntax Visual Basic Sub AddCcRecipient objMailAddress As AddEmailLib MailAddress Example Copyright c 2004 2010 Traysoft Inc All rights reserved 81 AddEmail 3 0 User Manual 3 2 18 Dim objMailAddress As New AddEmailLib MailAddress objMailAddress Address someone someisp com objMailMessage AddCcRecipient objMailAddress VBScript Sub AddCcRecipient objMailAddress Example Dim objMailAddress Set objMailA
49. at for SPA authentication 3 1 8 MaxThreads Property MaxThreads property specifies the maximum number of threads that SmtpMail object can create when sending messages asynchronously using SendAsync Enterprise version only Syntax Visual Basic objSmtpMail MaxThreads 10 VBScript objSmtpMail MaxThreads 10 C objSmtpMail MaxThreads 10 C HRESULT get_MaxThreads LONG HRESULT put_MaxThreads LONG spSmtpMail gt PutMaxThreads 10 Remarks Default value of MaxThreads property is 5 accepted range is 1 1000 AddEmail supports simultaneous sending of several messages This feature is useful if application has to send a large number of messages especially if messages are sent directly without using outgoing mail server Copyright c 2004 2010 Traysoft Inc All rights reserved 49 AddEmail 3 0 User Manual 3 1 10 SmtpMail object creates one or more worker threads that send messages from its message queue MaxThreads property limits the number of threads that are running at the same time therefore setting the limit on the number of simultaneously transferred messages MaxThreads property is available only in AddEmail Enterprise version AddEmail Professional always uses one thread to send messages SenderHostname Property Use SenderHosiname property to specify fully qualified hostname of the computer that sends e mail messages Enterprise ver
50. canceled when its status changes to MailStatusCanceled Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 64 3 1 23 GetLastErrorCode Method GetLastErrorCode method returns error code of the last synchronous send operation Syntax Visual Basic Function GetLastErrorCode As Long Example numErrorCode objSmtpMail GetLastErrorCode VBScript Function GetLastErrorCode Example numErrorCode objSmtpMail GetLastErrorCode C int GetLastErrorCode Example int numErrorCode objSmtpMail GetLastErrorCode C HRESULT GetLastErrorCode LONG pnumErrorCode Example int numErrorCode spSmtpMail gt GetLastErrorCode Parameters None Return value Returns numeric error code 0 if the last message was sent successfully 1 if connection to the server failed or in case of other Winsock errors gt 0 SMTP error code as defined in RFC 821 page 34 35 Remarks GetLastErrorCode can be used to obtain error code of the last synchronous send operation i e the error code from the last call of Send SimpleSend SimpleSendAttachment SimpleSendScriptable or SimpleSendAttachmentScriptable Copyright c 2004 2010 Traysoft Inc All rights reserved 65 AddEmail 3 0 User Manual 3 1 24 GetLastErrorDescription Method GetLastErrorDescription method returns error description of th
51. ceaterdecds sauesdereaded decesstecaueidecesdueeveueseneeseccerauveed 61 Camel Method ssnin enaena deztscscbececescecchiecctetvices saezeazestcepaacodvanesctecstaessaeeess Baena paasa Siei adapa a Tiaia 62 CancelAll Method ws 63 GetLastErrorCode Method ccistnc2eccccse cect cock cotecececdvend cece ctcapeccue souk cauesenerstecsadecccupengieqcue couecoceritea sececocupecersccuesnetces 64 GetLastErrorDescription Method caiciiaccicccctececccteseccecedccaisatep ences sdevect saterdeded coed sadetendes seuesctesatesdededvaedvedevanercedecraneeel 65 GetQueueSize Method 32s scccsscessecssecescsceccensceecetesscceecesteds sectecceces ces detdsccersccesvadssaceedtece aces setesccetsnces sede tateseterecces daneses 66 OnStatusChange Event sieneen Aaaa ccc cate aa E ea Eaa EAA E AE E Re aaa EAEan E Aaa ENARA SEa Eaa iaaa 66 OnProgress Event sssesesseeeeees ws 67 OnStatusChangeHandler Property saisi lt cc22sccecccceseccececceasceder coded deeeect centarcecaecuaeseuependeddacesct center deces duaeredecuneeseecersuven 68 OnProgressHandler Property wzscccsczcesseccsce sess ce tesscectecsscadesccs ecctde aces cenesccdesceas vids scueeaabcescaecebscccertieasvddvseccedsoyeccadeenescd 68 2 MailMessage Overview Sender Property cicccieccccsccscctycecenckh ceceesceectees aceacetscetendes tesao cece e aenep a h cetsndeyceasestusvaeessteveauesecetencesscesestuecterseueercueses 70 Reply To Property sccisccciecececcecectcccczcesccccctscccgacecseddectet ccces se
52. com objRecipient Name Jane Smith objMessage AddRecipient objRecipient Copyright c 2004 2010 Traysoft Inc All rights reserved 37 AddEmail 3 0 User Manual 2 11 2 Setup second recipient objRecipient New AddEmailLib MailAddressClass objRecipient Address james someserver com objRecipient Name James Smith objMessage AddRecipient objRecipient Send prepared message synchronously Dim strError As String Dim resultCode As Integer resultCode objSmtpMail Send objMessage True strError If resultCode 0 Then E mail was sent successfully Else Send failed strError contains detailed error description End If Alternatively send prepared message asynchronously Dim messageNumber As Integer messageNumber objSmtpMail SendAsync objMessage True Save the message number It is used to retrieve the status of the message 6 If the message was sent asynchronously use GetStatus to check the status of the message Dim messageStatus As AddEmailLib MailStatus messageStatus objSmtpMail GetStatus messageNumber Select Case messageStatus Case AddEmailLib MailStatus MailStatusQueued Case AddEmailLib MailStatus MailStatusSending Case AddEmailLib MailStatus MailStatusSent E mail was sent successfully Case AddEmailLib MailStatus MailStatusFailed E mail wasn t sent Dim errorCode As Integer
53. cription numMessageNumber Parameters numMessageNumber in Message number returned from the SendAsync method Return value Returns extended error information if the message failed to be sent empty string otherwise Remarks SendAsync method places a message into a message queue and returns message number which Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 62 identifies the message If message failed to be sent status of the message becomes MailStatusFailed and GetErrorDescription method can be used to obtain error description 3 1 21 Cancel Method Cancel method cancels sending of a message that was queued for sending using SendAsync method Syntax Visual Basic Sub Cancel numMessageNumber As Long Example objSmtpMail Cancel numMessageNumber VBScript Sub Cancel numMessageNumber Example objSmtpMail Cancel numMessageNumber C void Cancel int numMessageNumber Example objSmtpMail Cancel numMessageNumber C HRESULT Cancel LONG numMessageNumber Example spSmtpMail gt Cancel numMessageNumber Parameters numMessageNumber in Message number returned from the SendAsync method Return value None Remarks SendAsync method places a message into a message queue and returns message number which identifies the message Use Cancel method to cancel sending of the message Only messages that
54. cs dccazezecceceeseassctetsccczweestanccezersuceescissctdsecarseets saerseuersucedtedys 71 MessageSubject Property ww 72 MessageBody Property ssoi arena aeaaeae te ra ae opaha Laa aae Peara Aaaa Eaa Pera aaa ide En Laau eiia aaas 72 MessageBodyFormat Property caicieccccc dccccicesccceass secasesecercecevsnaeeccececevese evnar at donara oiera cece shuce ceseeccsacdrsugeedes ceneeente 73 MessageBodyEn coding Property ssecsseecsesceseesseeesseeenenensnesneeesseeenenensneeseeesseeeneneseeeeaseesseeeaenessueeaseesneeetenereaee 74 MessageBodyCharset Property c c1ce cceresececenccenecenecesnencnccennereneeecaeconersnecennenenessnceneaeresneeconeeenecsoseennerencenecer 74 AltMessageBody Property 0 wee 75 AltMessageBodyEncoding Property cseccsssecsecsseesseeesseessenenenessneeaseesnenessnesseeessesenensesneeaneesseeesenesaeeesseeesenenes 76 AltMessageBodyCharset Property ccssscssessseesseeessnesseeesseeseenenenessneesseeenenssseesseeessesenenesseeeaseesseeesenasaneeaseeenenenes 76 MessagePriority Property e icicc0ccccccceccedeczcceseceee idsi siaran ionas iapa a ddued diao anid iyaa deaa idsi adiran idiei ridikoa 77 Copyright c 2004 2010 Traysoft Inc All rights reserved AddEmail 3 0 User Manual Messageld Property s s s MessageBodyFile Property RequestReadRecelpt Property qisicc ccccetecscecesecccettecetees idiari sodina eeror decereatiecseectbecauessiedeunesd
55. ction SendAsync objMessage As AddEmailLib MailMessage bUseSmtpServer As Boolean As Long Example Dim numMessageNumber As Long numMessageNumber objSmtpMail SendAsync ob jMessage True VBScript Function SendAsync objMessage bUseSmtpServer Example Dim numMessageNumber numMessageNumber objSmtpMail SendAsync objMessage True C int SendAsync AddEmailLib MailMessageClass objMessage bool bUseSmtpServer Example int numMessageNumber objSmtpMail SendAsync objMessage true C HRESULT SendAsync IMailMessage objMessage VARIANT_BOOL bUseSmtpServer LONG pnumResultCode Example int numMessageNumber spSmtpMail gt SendAsync objMessage TRUE Parameters objMessage in Prepared MailMessage object containing the e mail message to send bUseSmtpServer in Specifies whether the message should be sent using SMTP server If the parameter is true not equal to zero message will be send using SMTP server specified in SmtpServer property If the parameter is false equal to zero message will be send directly to the recipients mail server s This parameter is valid for AddEmail Enterprise version only AddEmail Professional always uses specified SMTP server Return value Returns message number which identifies this message Message number is used to obtain status of the message or cancel the message Remarks Copyright c 2004 2010 Traysoft Inc All
56. d If Snapshot 3 HTML message with attachments Dim objSmtpMail objMailMessage objMailAttachment objMailAddress strError numResultCode Set objSmtpMail CreateObject AddEmail SmtpMail objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword Create message and setup subject and body Set objMailMessage CreateObject AddEmail MailMessage objMailMessage MessageBodyFormat 1 HTML format objMailMessage MessageSubject test objMailMessage MessageBody lt html gt lt body gt lt b gt Testing lt b gt lt body gt lt html gt Add first attachment Set objMailAttachment CreateObject AddEmail MailAttachment objMailAttachment File c files docl pdf objMailMessage AddAttachment objMailAttachment Add second attachment Set objMailAttachment CreateObject AddEmail MailAttachment objMailAttachment File c files doc2 pdf Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 24 2 6 2 objMailMessage AddAttachment objMailAttachment Setup sender Set objMailAddress CreateObject AddEmail MailAddress objMailAddress Name John Smith objMailAddress Address jsmith myserver com objMailMessage Sender objMailAddress Setup first recipient Set objMailAddress CreateObject AddEmail MailAddre
57. d attachment objMailAttachment CREATEOBJECT AddEmail MailAttachment objMailAttachment File c files doc2 pdf objMailMessage AddAttachment objMailAttachment Setup sender objMailAddress CREATEOBJECT AddEmail MailAddress objMailAddress Name John Smith objMailAddress Address jsmith myserver com objMailMessage Sender objMailAddress Setup first recipient objMailAddress CREATEOBJECT AddEmail MailAddress objMailAddress Name Jane Smith objMailAddress Address jane someserver com objMailMessage AddRecipient objMailAddress Setup second recipient objMailAddress CREATEOBJECT AddEmail MailAddress objMailAddress Name James Smith objMailAddress Address james someserver com objMailMessage AddRecipient objMailAddress Send prepared messag numResultCode objSmtpMail Send objMailMessage t strError Copyright c 2004 2010 Traysoft Inc All rights reserved 41 AddEmail 3 0 User Manual 2 14 2 14 1 IF numResultCode 0 THEN MESSAGEBOX Sent successfully ELSE MESSAGEBOX strError ENDIF Please refer to the Reference section of this manual for detailed description of AddEmail objects methods and properties PowerBuilder Using AddEmail in PowerBuilder projects AddEmail ActiveX can be used to send e
58. dEmail folder You should see a message saying that the dil was registered successfully Automatic import of HTML with embedded images With new version your program can automatically create HTML emails with embedded images by importing HTML files from disk AddEmail imports specified HTML file adds all images referenced in the HTML as inline attachments and modifies HTML as needed Please refer to ImportHTML and SimpleSendHtml topics for more information SimpleSendXXX methods allow to specify sender s and recipients names New version adds support for First LastName lt name domain com gt format to SimpleSend SimpleSendHtml and SimpleSendAttachment methods Now you can specify names in addition to e mail addresses for sender and recipients in SimpleSendXXX methods Support for Unicode non ASCII attachment names New version supports Unicode characters in MailAttachment File and MailAttachment Name properties AddEmail will automatically encode attachment name if it has any non ASCII characters ReplyTimeout property New property has been added to specify how long AddEmail waits for a response from SMTP server before reporting timeout error Please refer to ReplyTimeout topic for more information What s new in version 2 0 AddEmail ActiveX 2 0 adds many new features and improvements while maintaining complete compatibility with previous versions Source code written for AddEmail ActiveX 1 x should compile and work with AddEma
59. ddEmailLib IMailMessagePtr spMessage spMessage CreateInstance __uuidof AddEmailLib MailMessage spMessage gt PutMessageSubject test spMessage gt PutMessageBody Test message Setup sender AddEmailLib IMailAddressPtr spFrom spFrom CreateInstance __uuidof AddEmailLib MailAddress spFrom gt PutAddress jsmith myserver com spFrom gt PutName John Smith spMessage gt PutSender spFrom Setup first recipient AddEmailLib IMailAddressPtr spTo spTo CreateInstance __uuidof AddEmailLib MailAddress spTo gt PutAddress jane someserver com spTo gt PutName Jane Smith spMessage gt AddRecipient spTo Setup second recipient spTo CreateInstance __uuidof AddEmailLib MailAddress spTo gt PutAddress james someserver com spTo gt PutName James Smith spMessage gt AddRecipient spTo Send prepared messag BSTR bstrError int resultCode m_spSmtpMail gt Send spMessage TRUE amp bstrError if resultCode 0 E mail was sent successfully else Send failed bstrError contains detailed error description Alternatively send prepared message asynchronously int messageNumber m_spSmtpMail gt SendAsync spMessage TRUE 6 If the e mail is sent asynchronously your application will need to process events to find out when the
60. ddress CreateObject AddEmail MailAddress objMailAddress Address someone someisp com objMailMessage AddCcRecipient objMailAddress C void AddCcRecipient AddEmailLib MailAddressClass objMailAddress Example AddEmailLib MailAddressClass objMailAddress new AddEmailLib MailAddressClass j objMailAddress Address someone somesp com objMailMessage AddCcRecipient objMailAddress C HRESULT AddCcRecipient IMailAddress objMailAddress Example AddEmailLib IMailAddressPtr spMailAddress spMailAddress CreateInstance __uuidof AddEmailLib MailAddress spMailAddress gt PutAddress Someone someisp com spMailMessage gt AddCcRecipient spMailAddress Parameters objMailAddress in Prepared MailAddress object containing e mail address and name of the recipient Return value None Remarks Use AddCcRecipient method to add prepared MailAddress object containing e mail address and optional name of the recipient of e mail message E mail address and name will appear in the Cc field of the message Application can call AddCcRecipient method more than once to have more than one recipient in the Cc field AddBccRecipient Method AddBccRecipient method adds Bcc invisible recipient to e mail message Syntax Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 82 Visual Basic Sub AddBccRecipient objMail
61. de 0 Then E mail was sent successfully Else Send failed strError contains detailed error description End Tt Alternatively send prepared message asynchronously Dim messageNumber As Integer messageNumber objSmtpMail SendAsync objMessage True 5 If the e mail is sent asynchronously your application will need to process events to find out when the email was sent successfully or send operation failed Declare event handlers to process events from the SmtpMail object Private Sub OnStatusChange ByVal messageNumber As Integer ByVal newStatus As Integer Handles ob jSmtpMail OnStatusChange Event processing code End Sub Private Sub OnProgress ByVal messageNumber As Integer ByVal bytesSent As Integer ByVal bytesTotal As Integer Handles objSmtpMail OnProgress Event processing code End Sub Please refer to the Reference section of this manual for detailed description of AddEmail objects methods and properties Included Visual Basic NET samples provide code snapshots for common operations such as sending text e mails sending HTML e mails adding attachments to e mails creating HTML e mails with embedded images Samples AddEmail includes the following Visual Basic NET samples SimpleSend Sample Location AddEmail Samples VB NET 2002 2003 SimpleSena AddEmail Samples VB NET 2005 2010 SimpleSend SimpleSend sample demonstrates how to send text or HTML e mails synchronously u
62. e MessageBodyEncoding AddEmailLib MailEncoding MailEncoding7Bit C HRESULT get_MessageBodyEncoding MailEncoding HRESULT put_MessageBodyEncoding MailEncoding spMailMessage gt PutMessageBodyEncoding AddEmailLib MailEncoding7Bit Remarks MessageBodyEncoding property indicates which encoding method should be used for main body of the message Possible encoding values are defined in the MailEncoding enumeration Default value of MessageBodyEncoding property is MailEncodingDefault which means that AddEmail will try to determine best encoding method based on the content of message body Application can specify encoding method to save time needed to analyze message body Use MailEncoding7Bit if message body contains only English ASCII characters 32 126 and line length does not exceed 76 characters Use MailEncoding8Bit if message body contains non English ASCII characters and line length does not exceed 76 characters Use MailEncodingQuotedPrintable if line length exceeds 76 characters and formatting should be preserved Use MailEncodingBase64 for Unicode messages or if message body contains many non English ASCII characters For HTML messages MailEncodingBase64 or MailEncodingQuotedPrintable is recommended MessageBodyCharset Property MessageBodyCharset property specifies character set of main body of e mail message Syntax Visual Basic objMailMessage MessageBodyCh
63. e last synchronous send operation Syntax Visual Basic Function GetLastErrorDescription As String Example Dim strError As String strError objSmtpMail GetLastErrorDescription VBScript Function GetLastErrorDescription Example Dim strError strError objSmtpMail GetLastErrorDescription C string GetLastErrorDescription Example string strError objSmtpMail GetLastErrorDescription C HRESULT GetLastErrorDescription BSTR pstrError Example _bstr_t strError spSmtpMail gt GetLastErrorDescription j Parameters None Return value Returns extended error information if the last message failed to be sent empty string otherwise Remarks If programming language you are using does not support out parameters JavaScript for example GetLasiErrorDescription can be used to obtain extended error information of the last synchronous send operation i e the error description from the last call of Send SimpleSend SimpleSendAttachment SimpleSendScriptable or SimpleSendAttachmentScriptable Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 66 3 1 25 GetQueueSize Method GetQueueSize method returns number of e mail messages queued for sending Syntax Visual Basic Function GetQueueSize As Long Example numMessages objSmtpMail GetQueueSize VBScript Function
64. e of attachment data Return value None Remarks Use LoadFromMemory method to create in memory attachment File property is not used in this case Application should set Name property to specify name of the attachment displayed in the e mail MailAddress Overview MailAddress object represents e mail address Syntax Visual Basic Dim objMailAddress As New AddEmailLib MailAddress objMailAddress Address someone someisp com VBScript Dim objMailAddress Set objMailAddress CreateObject AddEmail MailAddress objMailAddress Address someone someisp com C AddEmailLib MailAddressClass objMailAddress new AddEmailLib MailAddressClass j objMailAddress Address someone someisp com C AddEmailLib IMailAddressPtr spMailAddress spMailAddress CreateInstance __uuidof AddEmailLib MailAddress spMailAddress gt PutAddress someone someisp com Properties Address E mail address Name Name as it should appear in e mail message Address Property Address property specifies e mail address of recipient or sender Syntax Copyright c 2004 2010 Traysoft Inc All rights reserved Reference Visual Basic 96 objMailAddress Address VBScript smithj someisp com objMailAddress Address C smithj someisp com objMailAddress Address C smithj someisp com HRE
65. e refer to SendAsync Method if you want to send messages without blocking your application SimpleSendAttachment Method SimpleSendAttachment method sends simple text or HTML e mail with attachments to one or more recipients synchronously Syntax Visual Basic Function SimpleSendAttachment strFrom As String strTo As String strSubject As String strMessage As String strAttach As String ByRef strError As String As Long Example Dim strError As String Dim numResultCode As Long numResultCode ob jSmtpMail SimpleSendAttachment My Name lt me myisp com gt Someone lt someone someisp com gt someoneelse someotherisp com test Test message c files docl pdf c files doc2 pdf strError VBScript Function SimpleSendAttachmentScriptable strFrom strTo strSubject strMessage strAttach ByRef strError Example Dim strError Dim numResultCode numResultCode objSmtpMail SimpleSendAttachmentScriptable My Name lt me myisp com gt Someone lt someone someisp com gt someoneelse someotherisp com test Test message c files docl pdf c files doc2 pdf strError C int SimpleSendAttachment string strFrom string strTo string strSubject string Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 52 strMessage string strAttach out string strError Example string strError int numResultCode objSmtpMail Simple
66. eced ANRA AERA RAEAN ARANERREKA 97 Index 100 Copyright c 2004 2010 Traysoft Inc All rights reserved Introduction 4 1 1 1 2 Introduction Overview Overview of AddEmail ActiveX The AddEmail ActiveX enables your application to send e mail messages AddEmail was designed to work with all development environments that support COM objects ActiveX or OCX controls Easy to use and flexible object model allows application developers to implement e mail support without a time consuming learning curve AddEmail was developed for today s most demanding applications and was thoroughly tested to ensure enterprise level reliability and stability The AddEmail ActiveX license agreement allows you to embed and distribute AddEmail within your application royalty free Main features of AddEmail ActiveX are Send e mails using SMTP and ESMTP protocols with optional authentication and SSL encryption Send text or HTML e mails with any number of attachments Create or import HTML e mails with embedded images Supports e mails with multiple recipients in To Cc and Bcc fields Sends large e mails asynchronously without blocking your application Progress and status events allow to implement user friendly UI progress indicator cancel button etc e Sends several e mails simultaneously without any multi threading support in your application AddEmail Enterprise version only e Sends e mails directly to recipients mail ser
67. eceseateccdes sedecanescuseecr 79 AddRecipient Method ticc2 cc 20cccsccrecccsenncccetecseccateescecencapeecesensnceddensusdeteeauetcoceseecestnueseetessecsetcenuescecesscceranneccevensecctvens 79 AddGcRecipient Method cis scccccoscccccstecccced ceccccctccececescees cette steed crecccucsecedceces secs cehesencessbececuesheedceeessecseavecotercoueesouesee 80 AdGdGBccRecipient Method cc 02 c c cccccccecece cenceeccdsccecs cesects codes ceces ccnecesedancectdesseudsecesdtecsupieecscceuerdecerscedseccedtersectecese 81 AdGAttachiment Method icc iisonic iosi aseron cecescesdedveebes cues cteedavesececsudersedseeued dcenesteedeuesecerenceysdueeesececerectecdantecs 83 AddHeader Method 84 ClearAttachments Method 85 ClearRecipients Method 85 ClearGcRecipients Method jinisc 2ccccacccecetecccscescccee ctccasececcdcteceiccccaueceteqens deccuectcctatecsivereaeycecc esedeceaecbudcouereteerecareecceeate 86 ClearBccRecipients Method c2icccsc lt ccccesiccececes cece secectcectercaeesaccecaceectcvencecieuseotetancesuccesacyectey ceeeescusestesebecsucdesneseczeztene 87 IMPOrtHT ML Meth i262 cicecsicecccssceccecee secs esac coceseevdencenceccecevsecsedetecucestecevcesetuesdecevsvevedes ecevshecrvendebiesaccrsaeeeecesceneseuse 88 SD MAIL ATACIIMG INE a E E AE Overview ascdevcnscctsicocneceiecsdenstersscceneseccssvcoceeceincsnersienediceietezennnesstccevecscetsinceneseieteveesters ecenedetcsstecsiieiviccenersiesescetierrs File Property
68. eipt for the message is requested Syntax Visual Basic objMailMessage RequestReadReceipt Tru VBScript objMailMessage RequestReadReceipt Tru C objMailMessage RequestReadReceipt true C HRESULT get_RequestReadReceipt VARIANT_BOOL HRESULT put_RequestReadReceipt VARIANT_BOOL spMailMessage gt PutRequestReadReceipt VARIANT_TRUE Remarks Set RequestReadReceipt to True if you want to request a read receipt for the message Default value of RequestReadReceipt property is False AddRecipient Method AddRecipient method adds recipient to the To field of e mail message Syntax Visual Basic Sub AddRecipient objMailAddress As AddEmailLib MailAddress Example Dim objMailAddress As New AddEmailLib MailAddress objMailAddress Address someone someisp com objMailMessage AddRecipient ob jMailAddress VBScript Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 80 3 2 17 Sub AddRecipient objMailAddress Example Dim objMailAddress Set objMailAddress CreateObject AddEmail MailAddress objMailAddress Address someone someisp com objMailMessage AddRecipient objMailAddress C void AddRecipient AddEmailLib MailAddressClass objMailAddress Example AddEmailLib MailAddressClass objMailAddress new AddEmailLib MailAddressCl
69. end Method araara te Lace eats eaa cate aaae ra aAA Aaaa Eae aE A a a e aA AAE stuns esasecvusdearsbeasradyens 49 SimpleSendAttachment Method gicicics cescnc cscs covets secdeees cccvctcacessnseces cevececersucas eaescecepeceensten ceuececerfueesscoreocersatveccuesbeses 51 SimpleSendHtmi Method jee cco see ecsccstececdaddece entetatecceceecocesedercodedddevectccatarsecdecoueretetendddtecesctecaterdecessuesveuesundesedesranven 53 SerialNumber Property a zccecscccssccsseccecss cccosssctecetesscccvecsstecvanns ca eie aepo aia aapa ra aapa send cetesccesvieasbedstacaccsbyeccoesanesed 54 ConnectAttempts Property lt i OD ReplyTimeout Property cccecseseeessseeeeseneeessneesesseeeeeseneeesseesassaeeeaseneeessneeseseaesesseneeessneesasaaessaseneeensneeeassaeeeasenee 56 Send Method siiis ceed Seer cect cece decccdecerel lac edevectetaneedecevenadcabeyebcad edevectccaterdecudveadsaveiences sdavsctesates deduyvaadeecesuncecdaszaneens 56 S ndAsyne Method ssecztes di ccesccececeseeksuseecceaescncetensccesscaseecs aatenccoues ce dundscccestcesvedeautensteassdee duicscuerstuesvedstaneedzerecceedaneses 58 GetStatirs Method ree eraa rae E aa ceca aA a Ee a EAA EKA r EEAS EKAA S aA KRE aE KANA a AKAA EESE TEN 59 GetErr rCode Method 92s iscecsecersecs ccscctsepctene cca ceuets secdtted cacvct cep cacuesces douececenstees edesctcapeceeescex seuececertiees EANN iaraa a addni ins 60 GetErrorDescription Method i cicc25cciecoceccczdeiceseetacedccdecoac sedan enddd ecdect
70. erty SmtpSSL property specifies whether outgoing mail server requires an encrypted connection TLS SSL Syntax Visual Basic objSmtpMail SmtpSSL True VBScript objSmtpMail SmtpSSL True C objSmtpMail SmtpSSL true C HRESULT get_SmtpSSL VARIANT_BOOL HRESULT put_SmtpSSL VARIANT_BOOL spSmtpMail gt PutSmtpSSL VARIANT_TRUE Remarks SmtpSSL property is False by default Set SmtpSSL property to True if you want to use TLS SSL connection for example when using smtp gmail com server on port 465 SmtpSPA Property SmtpSPA property specifies whether to use Secure Password Authentication SPA method SPA is supported by Microsoft Exchange Windows 2000 Server and Windows 2003 Server Syntax Visual Basic Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 48 objSmtpMail SmtpSPA True VBScript objSmtpMail SmtpSPA True C objSmtpMail SmtpSPA true C HR HR spSmtpMail gt PutSmtpSPA VARIANT_TRUE Remarks ESUL ESUL get_SmtpSPA VARIANT_BOO put_SmtpSPA VARIANT_BOO SmtpSPA property is False by default If your outgoing mail server requires SPA please set SmtpSPA property to True in order to use Secure Password Authentication Please note that some servers are configured to require SmtpUsername in username domain com form
71. erver is terminated and timeout error is reported You might want to set ReplyTimeout to 60 120 seconds if your outgoing mail server is slow and you get timeout errors with the default value Send Method Send method sends e mail message synchronously Syntax Visual Basic Function Send objMessage As AddEmailLib MailMessage bUseSmtpServer As Boolean ByRef strError As String As Long Example Dim strError As String Dim numResultCode As Long numResultCode objSmtpMail Send objMessage True strError VBScript Copyright c 2004 2010 Traysoft Inc All rights reserved 57 AddEmail 3 0 User Manual Function SendScriptable objMessage bUseSmtpServer ByRef strError Example Dim strError Dim numResultCode numResultCode objSmtpMail SendScriptable objMessage True strError C int Send AddEmailLib MailMessageClass objMessage bool bUseSmtpServer out string strError Example string strError int numResultCode objSmtpMail Send objMessage true out strError C HRESULT Send IMailMessage objMessage VARIANT_BOOL bUseSmtpServer BSTR pstrError LONG pnumResultCode Example BSTR bstr int numResultCode spSmtpMail gt Send objMessage TRUE amp bstr _bstr_t strError bstr FALSE Parameters objMessage in Prepared MailMessage object containing the e mail message to send bUseSmtpServe
72. essage MessageBody Test message Setup sender MailAddressClass objSender new MailAddressClass j objSender Address jsmith myserver com objSender Name Jane Smith objMessage Sender ob jSender Setup first recipient MailAddressClass objRecipient new MailAddressClass j objRecipient Address jane someserver com objRecipient Name Jane Smith objMessage AddRecipient objRecipient Setup second recipient objRecipient new MailAddressClass objRecipient Address james someserver com objRecipient Name James Smith objMessage AddRecipient objRecipient Send prepared message synchronously string strError int resultCode ob jSmtpMail Send objMessage true out strError if resultCode 0 E mail was sent successfully else Send failed strError contains detailed error description Alternatively send prepared message asynchronously int messageNumber objSmtpMail SendAsync objMessage true Save the message number It is used to retrieve the status of the message 6 If the message was sent asynchronously use GetStatus to check the status of the message AddEmailLib MailStatus messageStatus objSmtpMail GetStatus messageNumber switch messageStatus case AddEmailLib MailStatus MailStatusQueued break case AddEmailLib MailStatus MailStatusSending brea
73. ge asynchronously var messageNumber messageNumber objSmtpMail SendAsync objMailMessage true Save the message number It is used to retrieve the status of the message 6 If the message was sent asynchronously use GetStatus to check the status of the message var numStatus numStatus objSmtpMail GetStatus numMessageNumber switch numStatus case 0 MailStatusQueued Response Write Queued break case 1 MailStatusSending Response Write Sending break case 2 MailStatusSent Response Wri break case 3 MailStatusFailed Response Write Error Response Write objSmtpMail GetErrorCode numMessageNumber Response Write lt BR gt Response Write objSmtpMail GetErrorDescription numMessageNumber ct Sent successfully break case 4 MailStatusCanceled Response Write Message canceled break Please refer to the Reference section of this manual for detailed description of AddEmail objects methods and properties Included ASP samples provide code snapshots for common operations such as sending text e mails and sending HTML e mails Samples AddEmail includes the following ASP JScript samples SimpleSend Sample Location AddEmail Samples ASP JScript SimpleSena SimpleSend sample demonstrates how to send text ot HTML e mails synchronously using SimpleSend HimIMail Sample Location AddEmai
74. have status MailStatusQueued or MailStatusSending can be canceled If the message is currently transferred and its status is MailStatusSending Cancel method doesn t cause the transfer to stop immediately Message is marked for cancellation and will be canceled some time later The message Copyright c 2004 2010 Traysoft Inc All rights reserved 63 AddEmail 3 0 User Manual 3 1 22 is actually canceled when its status changes to MailStatusCanceled CancelAll Method CancelAll method cancels sending of all messages that were queued for sending using SendAsync method Syntax Visual Basic Sub CancelAl1 Example objSmtpMail CancelAll VBScript Sub CancelAl1 Example objSmtpMail CancelAll C void Cancel Example objSmtpMail CancelAll C HRESULT CancelAll Example spSmtpMail gt CancelAll Parameters None Return value None Remarks SendAsync method places a message into a message queue and returns message number which identifies the message Use CancelAll method to cancel sending of all messages that were not sent yet Only messages that have status MailStatusQueued or MailStatusSending will be canceled If a message is currently transferred and its status is MailStatusSending CancelAll method doesn t cause the transfer to stop immediately Message is marked for cancellation and will be canceled some time later The message is actually
75. he form Select ActiveX tab of Components palette click SmtpMail and drag a rectangle on the form AddEmail control is not visible on runtime so you can place it anywhere on the form 3 To process events from SmtpMail object create event handlers Click SmtpMail on the form and select Events tab in the Object Inspector window You will see 2 events OnProgress and OnStatusChange Double click dropdown box next to event name to create event handler Please refer to the Reference section of this manual for detailed description of AddEmail objects methods and properties Included Delphi samples provide code snapshots for common operations such as sending text e mails sending HTML e mails adding attachments to e mails and processing Copyright c 2004 2010 Traysoft Inc All rights reserved 39 AddEmail 3 0 User Manual 2 12 2 2 13 2 13 1 events Samples AddEmail includes the following Delphi samples SimpleSend Sample Location AddEmail Samples Delphi 7 SimpleSena SimpleSend sample demonstrates how to send text or HTML e mails synchronously using SimpleSend SimpleSendAttachment Sample Location AddEmail Samples Delphi 7 SimpleSendAttachment SimpleSendAttachment sample demonstrates how to send text or HTML e mails with attachments synchronously using SimpleSendAttachment Him Mail Sample Location AddEmail Samples Delphi 7 HtmIMail HtmIMail sample demonstrates how to send HTML e mails with attachmen
76. hments synchronously using SendScriptable This sample also shows how to set alternative text only body of e mail ImportHtm IWithImages Sample Copyright c 2004 2010 Traysoft Inc All rights reserved 25 AddEmail 3 0 User Manual 2 7 2 7 1 Location AddEmail Samples VBS ImportHtm Withimages ImportHtmlWithImages sample demonstrates how to import HTML file with embedded images using ImportHTML EmbeddedImages Sample Location AddEmail Samples VBS Embeddedimages Embeddedimages sample demonstrates how to create and send HTML e mails with embedded images using Send JScript Using AddEmail in JScript projects AddEmail ActiveX can be used with any environment that supports JScript Windows has built in JScript support and can execute JScript files that have JS extension To use AddEmail ActiveX from JScript code create SmtpMail object and send a message using SimpleSendScriptable SimpleSendAttachmentScriptable or SendScriptable Please use code snapshots below to get started Snapshot 1 simple text email var ob jSmtpMail strError numResultCode objSmtpMail new ActiveXObject AddEmail SmtpMail objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword numResultCode objSmtpMail SimpleSendScriptable jsmith myserver com jJane someserver com james someserver com test Test message strError if numResultCode
77. ib MailStatus messageStatus spSmtpMail gt GetStatus numMessageNumber Parameters numMessageNumber in Message number returned from the SendAsync method Return value Returns status of the e mail message Message status values are defined in MailStatus enumeration Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 60 3 1 19 Remarks SendAsync method places a message into a message queue and returns message number which identifies the message Use GetStatus method to obtain information about a status of the message GetErrorCode Method GetErrorCode method obtains error code for a message that was queued for sending using SendAsync method and failed to be sent Syntax Visual Basic Function GetErrorCode numMessageNumber As Long As Long Example numErrorCode ob jSmtpMail GetErrorCode numMessageNumber VBScript Function GetErrorCode numMessageNumber Example numErrorCode objSmtpMail GetErrorCode numMessageNumber C int GetErrorCode int numMessageNumber Example int numErrorCode objSmtpMail GetErrorCode numMessageNumber C HRESULT GetErrorCode LONG numMessageNumber LONG pnumErrorCode Example int numErrorCode spSmtpMail gt GetErrorCode numMessageNumber Parameters numMessageNumber in Message number returned from the SendAs
78. il ActiveX 2 0 without any modifications New features added to version 2 0 are listed below Secure connection TLS SSL support Version 2 0 supports encrypted TLS SSL connection to SMTP servers Set SmtpSSL property to True if you want to use TLS SSL connection for example when using smtp gmail com server on port 465 Secure Password Authentication SPA support Version 2 0 supports Secure Password Authentication SPA If your SMTP server requires SPA please set SmtpSPA property to True in order to use SPA authentication method Please note that some servers are configured to require SmtpUsername in username domain com format for SPA authentication Windows Vista support Version 2 0 was extensively tested on Windows Vista and supports all Windows Vista editions Please note that new security feature of Windows Vista called User Account Protection UAP prevents regular programs from writing to the HKEY_CLASSES_ ROOT registry branch Because of that administrator privileges are required to register AddEmail dll on Windows Vista Only registration requires administrator privileges After AddEmail dll is registered on the target computer it can be used to send e mails from any program without administrator privileges New features of SimpleSend methods Copyright c 2004 2010 Traysoft Inc All rights reserved Introduction 6 Version 2 0 adds new SimpleSendAttachment method which allows to send text or HTML e mails
79. ilLib MailMessageClass objMessage MessageSubject test objMessage MessageBody Test message Setup sender MailAddressClass objSender new MailAddressClass objSender Address jsmith myserver com objSender Name Jane Smith objMessage Sender objSender Setup first recipient MailAddressClass objRecipient new MailAddressClass j objRecipient Address jane someserver com objRecipient Name Jane Smith objMessage AddRecipient objRecipient Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 16 2 3 2 Setup second recipient objRecipient new MailAddressClass objRecipient Address james someserver com objRecipient Name James Smith objMessage AddRecipient objRecipient Send prepared message synchronously string strError int resultCode ob jSmtpMail Send objMessage true out strError if resultCode 0 E mail was sent successfully else Send failed strError contains detailed error description Alternatively send prepared message asynchronously int messageNumber objSmtpMail SendAsync objMessage true 6 If the e mail is sent asynchronously your application will need to process events to find out when the email was sent successfully or send operation failed To process events from the SmtpMail object declare event handler
80. k case AddEmailLib MailStatus MailStatusSent E mail was sent successfully break case AddEmailLib MailStatus MailStatusFailed E mail wasn t sent Copyright c 2004 2010 Traysoft Inc All rights reserved 35 AddEmail 3 0 User Manual 2 10 2 2 11 2 11 1 int errorCode objSmtpMail GetErrorCode messageNumber string errorDescription objSmtpMail GetErrorDescription messageNumber break case AddEmailLib MailStatus MailStatusCanceled break Please refer to the Reference section of this manual for detailed description of AddEmail objects methods and properties Included ASP NET samples provide code snapshots for common operations such as sending text e mails and sending HTML e mails Samples AddEmail includes the following ASP NET C samples SimpleSend Sample Location AddEmail Samples ASP NET 1 x C SimpleSena AddEmail Samples ASP NET C SimpleSena SimpleSend sample demonstrates how to send text or HTML e mails synchronously using SimpleSend Him Mail Sample Location AddEmail Samples ASP NET 1 x C HtmiMail AddEmail Samples ASP NET C HtmiMail HtmlMail sample demonstrates how to send HTML e mails synchronously using Send This sample also shows how to set alternative text only body of e mail UnicodeMail Sample Location AddEmail Samples ASP NET 1 x C UnicodeMail AddEmail Samples ASP NET C Unic
81. l Samples ASP JScript Htm Mail HtmlMail sample demonstrates how to send HTML e mails synchronously using SendScriptable This sample also shows how to set alternative text only body of e mail UnicodeMail Sample Copyright c 2004 2010 Traysoft Inc All rights reserved 33 AddEmail 3 0 User Manual 2 10 2 10 1 Location AddEmail Samples ASP JScript UnicodeMail UnicodeMail sample demonstrates how to create and send e mails that contain Unicode characters Unicode can be used in the body of a message in the subject field and in the names of sender and recipients SendAsync Sample Location AddEmail Samples ASP JScript SendAsync SendAsync sample demonstrates how to send HTML e mails asynchronously using SendAsync method This sample also shows how to get status of the e mail using GetStatus ASP NET C Using AddEmail in ASP NET C projects To use AddEmail in your ASP NET C project perform the following steps 1 Add a reference to the AddEmail library In Visual Studio main menu select View gt Solution Explorer to open Solution Explorer Right click on the project that will use AddEmail and select Add Reference from the pop up menu Click COM tab find and select AddEmail 3 0 Type Library click Select button then OK button 2 Declare variable that will hold a reference to the SmtpMail object AddEmailLib SmtpMailClass objSmtpMail 3a Create an instance of the SmtpMail object
82. l in VBScript projects AddEmail ActiveX can be used with any environment that supports VBScript Windows has built in VBScript support and can execute VBScript files that have VBS extension To use AddEmail Activex from VBScript code create SmtpMail object and send a message using SimpleSendScriptable SimpleSendAttachmentScriptable or SendScriptable Please use code snapshots below to get started Snapshot 1 simple text email Dim objSmtpMail strError numResultCode Set objSmtpMail CreateObject AddEmail SmtpMail objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword numResultCode objSmtpMail SimpleSendScriptable jsmith myserver com jJane someserver com james someserver com test Test message strError If numResultCode 0 Then MsgBox Sent successfully Else MsgBox strError End If Snapshot 2 text email with attachments Dim objSmtpMail strError numResultCode Set objSmtpMail CreateObject AddEmail SmtpMail objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword numResultCode objSmtpMail SimpleSendAttachmentScriptable jsmith myserver com jJane someserver com james someserver com test Test message co files docl pdf c files doc2 pdf strError If numResultCode 0 Then MsgBox Sent successfully Else MsgBox strError En
83. l in your C project perform the following steps 1 Add a reference to the AddEmail library In Visual Studio main menu select View gt Solution Explorer to open Solution Explorer Right click on the project that will use AddEmail and select Add Reference from the pop up menu Click COM tab find and select AddEmail 3 0 Type Library click Select button then OK button 2 Declare variable that will hold a reference to the SmtpMail object private AddEmailLib SmtpMailClass objSmtpMail 3 Create an instance of the SmtpMail object in the constructor of your class objSmtpMail new AddEmailLib SmtpMailClass 4 Set SMTP server address port username and password objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpPort 25 objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword 5a Send an e mail synchronously using SimpleSend or SimpleSendAttachment string strError int resultCode ob jSmtpMail SimpleSend jsmith myserver com jJane someserver com james someserver com test Test message out strError if resultCode 0 E mail was sent successfully else Send failed strError contains detailed error description 5b Alternatively create and fill MailMessage object and send it synchronously using Send or asynchronously using SendAsync Create message and setup subject and body MailMessageClass objMessage new AddEma
84. lAddress Name John Smith objMailAddress Address jsmith myserver com objMailMessage Sender ob jMailAddress Setup first recipient Set objMailAddress CreateObject AddEmail MailAddress objMailAddress Name Jane Smith objMailAddress Address jane someserver com Copyright c 2004 2010 Traysoft Inc All rights reserved 29 AddEmail 3 0 User Manual 2 8 2 objMailMessage AddRecipient objMailAddress Setup second recipient Set objMailAddress CreateObject AddEmail MailAddress objMailAddress Name James Smith objMailAddress Address james someserver com objMailMessage AddRecipient objMailAddress Send prepared message synchronously Dim strError numResultCode numResultCode objSmtpMail SendScriptable objMailMessage True strError If numResultCode 0 Then The email was sent successfully Response Write Sent successfully Else 1 4 The email was not sent strError contains error description Response Write strError End IE Alternatively send prepared message asynchronously Dim messageNumber messageNumber objSmtpMail SendAsync objMailMessage True Save the message number It is used to retrieve the status of the message 6 If the message was sent asynchronously use GetStatus to check the status of the message Dim numStatus numStatus objSmtpMail GetStatus nu
85. lication can specify encoding method to save time needed to analyze alternative message body Use MailEncoding7Bit if alternative message body contains only English ASCII characters 32 126 and line length does not exceed 76 characters Use MailEncoding8Bit if alternative message body contains non English ASCII characters and line length does not exceed 76 characters Use MailEncodingQuotedPrintable if line length exceeds 76 characters and formatting should be preserved Use MailEncodingBase64 for Unicode messages or if alternative message body contains many non English ASCII characters AltMessageBodyCharset Property AltMessageBodyCharset property specifies character set of alternative plain text body of e mail message Syntax Visual Basic objMailMessage AltMessageBodyCharset unicode VBScript objMailMessage AltMessageBodyCharset unicode Copyright c 2004 2010 Traysoft Inc All rights reserved 77 AddEmail 3 0 User Manual C objMailMessage AltMessageBodyCharset unicode C HRESULT get_AltMessageBodyCharset BSTR HRESULT put_AltMessageBodyCharset BSTR spMailMessage gt PutAltMessageBodyCharset unicode Remarks AltMessageBodyCharset indicates which character set should be used to display alternative body of the message Default value of AltMessageBodyCharset property is an empty string Most common values of AltMessageBodyCharset property a
86. lso specify recipient s name followed by the recipient s e mail address in angled brackets strSubject in Subject of the e mail message strFileName in Filename of the HTML file to be imported strError out Contains extended error information if the message failed to be sent empty string otherwise Return value Returns numeric result 0 if the message was sent successfully 1 if connection to the server failed or in case of other Winsock errors gt 0 SMTP error code as defined in RFC 821 page 34 35 Remarks SimpleSendHiml can be used to send HTML e mails with embedded images This method imports specified HTML file adds all images referenced in the HTML as inline attachments and modifies HTML as needed Only images located on disk are added as attachments Images from the web http or https links in HTML are not attached Please note that the current version of AddEmail does not import images specified in CSS using url values This method supports Unicode in the subject and body of the message as well as in the sender s and recipients names Please make sure HTML file uses UTF 8 encoding if you want to use Unicode AddEmail will create Unicode e mail UTF 8 encoding if any part of the message contains Unicode characters This method is synchronous it returns after the message was sent or after an error occuried Please use it with care because single threaded applications are blocked and can t process user inpu
87. mMessageNumber Select Case numStatus Case 0 MailStatusQueued Response Write Queued Case 1 MailStatusSending Response Write Sending Case 2 MailStatusSent Response Write Sent successfully Case 3 MailStatusFailed Response Write Error amp objSmtpMail GetErrorCode numMessageNumber Response Write lt BR gt amp objSmtpMail GetErrorDescription numMessageNumber Case 4 MailStatusCanceled Response Write Message canceled End Select Please refer to the Reference section of this manual for detailed description of AddEmail objects methods and properties Included ASP samples provide code snapshots for common operations such as sending text e mails and sending HTML e mails Samples AddEmail includes the following ASP VBScript samples SimpleSend Sample Location AddEmail Samples ASP VBScript SimpleSena SimpleSend sample demonstrates how to send text ot HTML e mails synchronously using SimpleSend method HimIMail Sample Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 30 2 9 2 9 1 Location AddEmail Samples ASP VBScript Htm Mail HtmiMail sample demonstrates how to send HTML e mails synchronously using SendScriptable method This sample also shows how to set alternative text only body of e mail UnicodeMail Sample Location AddEmail Samples ASP VBScript UnicodeMail UnicodeMail sample demonstrates how
88. mails from PowerBuilder applications To use AddEmail in your PowerBuilder project you need to add a code that creates SmtpMail object and sends a message using SimpleSend SimpleSendAttachment or Send Please use code snapshots below to get started Snapshot 1 simple text email OLEObject objSmtpMail string strError long numResultCode objSmtpMail Create OLEObject If objSmtpMail ConnectToNewObject AddEmail SmtpMail lt 0 Then Destroy objSmtpMail essageBox AddEmail Can t create AddEmail SmtpMail COM object Return End If objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword numResultCode objSmtpMail SimpleSend jsmith myserver com jJane someserver com james someserver com test Test message Ref strError If numResultCode 0 Then MessageBox AddEmail Sent successfully Else MessageBox AddEmail strError End If Destroy objSmtpMail Snapshot 2 text email with attachments OLEObject objSmtpMail string strError long numResultCode objSmtpMail Create OLEObject If objSmtpMail ConnectToNewObject AddEmail SmtpMail lt 0 Then Destroy objSmtpMail essageBox AddEmail Can t create AddEmail SmtpMail COM object Return End If objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword num
89. ment objMailAttachment cat ct ct objMailAttachment Create OLEObject objMailAttachment ConnectToNewObject AddEmail MailAttachment objMailAttachment File c files doc2 pdf objMailMessage AddAttachment objMailAttachment objMailAddress Create OLEObjec objMailAddress ConnectToNewObject AddEmail MailAddress objMailAddress Name John Smith objMailAddress Address jsmith myserver com objMailMessage Sender objMailAddress tf Gt objMailAddress ConnectToNewObject AddEmail MailAddress objMailAddress Name Jane Smith objMailAddress Address jane someserver com objMailMessage AddRecipient objMailAddress objMailAddress ConnectToNewObject AddEmail MailAddress objMailAddress Name James Smith objMailAddress Address james someserver com objMailMessage AddRecipient objMailAddress numResultCode objSmtpMail Send objMailMessage True Ref strError If numResultCode 0 Then MessageBox AddEmail Sent successfully Else MessageBox AddEmail strError End If Destroy objSmtpMail Destroy objMailMessage Copyright c 2004 2010 Traysoft Inc All rights reserved 43 AddEmail 3 0 User Manual Destroy objMailAddress Destroy objMailAttachment Please refer to the Reference section of this manual for detailed description of AddEmail objects methods and properties 3 Reference 3 1 Smt
90. message OnStatusChange event is used to notify application about changes to the message status Initially message status is MailStatusQueued When AddEmail starts sending the message its status changes to MailStatusSending When the message is sent successfully status changes to MailStatusSent Status becomes MailStatusFailed if AddEmail was unable to send the message If the message was canceled using Cancel or CancelAll method its status becomes MailStatusCanceled OnProgress Event OnProgress event is fired during message transfer to notify application about sending progress Syntax Visual Basic Sub OnProgress numMessageNumber As Long numBytesSent As Long numBytesTotal As Long C void OnProgress int numMessageNumber int numBytesSent int numBytesTotal C void __cdecl OnProgress LONG numMessageNumber LONG numBytesSent LONG numBytesTotal Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 68 3 1 28 3 1 29 Parameters numMessageNumber in Message number returned from the SendAsync method numBytesSent in Number of bytes transferred already numBytesTotal in Total number of bytes in the message Return value None Remarks OnProgress is fired after block of data is transferred In current version of AddEmail block size is 8 kilobytes If the total number of bytes in the message is smaller than the block size OnProgress event is not fired
91. mple Location AddEmail Samples VBS Embeddedimages Embeddedimages sample demonstrates how to create and send HTML e mails with embedded images using Send ASP VBScript Using AddEmail in ASP VBScript projects To use AddEmail in your ASP VBScript project perform the following steps 1 Optional If you are using Visual Interdev add a reference to the AddEmail library In Visual Interdev main menu select Project gt References Find and select AddEmail 3 0 Type Library 2 Declare variable that will hold a reference to the SmtpMail object Dim objSmtpMail 3a Create an instance of the SmtpMail object Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 28 Set objSmtpMail Server CreateObject AddEmail SmtpMail 3b If you are sending e mails asynchronously you will need to access the same SmtpMail object on more than one page In this case store an instance of the SmtpMail object in Session collection If IsEmpty Session SmtpMail Then Set objSmtpMail Server CreateObject AddEmail SmtpMail Set Session SmtpMail objSmtpMail Else Set objSmtpMail Session SmtpMail End If 4 Set SMTP server address port username and password objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpPort 25 objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword 5a Send an e mail synchronously using SimpleSendScriptable
92. ng probability that e mails sent using AddEmail will be blocked by a spam filter Read receipt support With previous versions of AddEmail custom header had to be added to the message to request a read receipt To request read receipt with version 2 0 set RequestReadReceipt property of MailMessage object to True 1 4 Legal Information Legal Information for AddEmail 3 0 User Manual While every precaution has been taken in the preparation of this document Traysoft Inc assumes no responsibility for errors or omissions or for damages resulting from the use of information contained in this document or from the use of programs and source code that may accompany it In no event shall Traysoft Inc be liable for any loss of profit or any other commercial damage caused or alleged to have been caused directly or indirectly by this document Information in this document is subject to change without notice and does not represent a commitment on the part of Traysoft Inc Companies names and data used in examples herein are fictitious unless otherwise noted No part of this document may be reproduced or transmitted in any form or by any means electronic or mechanical for any purpose unless expressly permitted by Traysoft Inc Traysoft Inc may have patents or pending patent applications trademarks copyrights or other intellectual property rights covering subject matter in this document The furnishing of this document does not give you any license
93. nt method more than once to specify more than one Bcc recipient Copyright c 2004 2010 Traysoft Inc All rights reserved 83 AddEmail 3 0 User Manual 3 2 19 AddAttachment Method AddAttachment method adds attachment to e mail message Syntax Visual Basic Sub AddAttachment objMailAttachment As AddEmailLib MailAttachment Example Dim objMailAttachment As New AddEmailLib MailAttachment objMailAttachment File c files document pdf objMailMessage AddAttachment ob jMailAttachment VBScript Sub AddAttachment objMailAttachment Example Dim objMailAttachment Set objMailAttachment CreateObject AddEmail MailAttachment objMailAttachment File c files document pdf objMailMessage AddAttachment objMailAttachment C void AddAttachment AddEmailLib MailAttachmentClass objMailAttachment Example AddEmailLib MailAttachmentClass objMailAttachment new AddEmailLib MailAttachmentClass objMailAttachment File c files document pdf objMailMessage AddAttachment objMailAttachment C HRESULT AddAttachment IMailAddress objMailAttachment Example AddEmailLib IMailAttachmentPtr spMailAttachment spMailAttachment CreateInstance __uuidof AddEmailLib MailAttachment spMailAttachment gt PutFile c files document pdf spMailMessage gt AddAttachment spMailAttachment Parameters objMailAttachment in
94. objMailAddress Setup second recipient Set objMailAddress CreateObject AddEmail MailAddress objMailAddress Name James Smith objMailAddress Address james someserver com objMailMessage AddRecipient objMailAddress Send prepared messag numResultCode objSmtpMail Send objMailMessage True strError If numResultCode 0 Then MsgBox Sent successfully Else MsgBox strError End If Please refer to the Reference section of this manual for detailed description of AddEmail objects methods and properties Samples AddEmail includes the following VBA samples SimpleSend Sample Location AddEmail Samples Access SimpleSend adp AddEmail Samples Excel SimpleSend xls SimpleSend sample demonstrates how to send text or HTML e mails synchronously using SimpleSend HimIMail Sample Location AddEmail Samples Access HtmIMail adp HtmlMail sample demonstrates how to send HTML e mails with attachments using Send This sample also shows how to set alternative text only body of e mail SendAsync Sample Location AddEmail Samples Access SendAsync adp HtmIMail sample demonstrates how to send HTML e mails with attachments asynchronously using SendAsync This sample also shows how to process events from SmtpMail object Copyright c 2004 2010 Traysoft Inc All rights reserved 23 AddEmail 3 0 User Manual 2 6 2 6 1 VBScript Using AddEmai
95. odeMail UnicodeMail sample demonstrates how to create and send e mails that contain Unicode characters Unicode can be used in the body of a message in the subject field and in the names of sender and recipients SendAsync Sample Location AddEmail Samples ASP NET 1 x C SendAsync AddEmail Samples ASP NET C SendAsync SendAsync sample demonstrates how to send HTML e mails asynchronously using SendAsync This sample also shows how to get status of the e mail using GetStatus ASP NET VB Using AddEmail in ASP NET VB projects To use AddEmail in your ASP NET VB project perform the following steps Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 36 1 Add a reference to the AddEmail library In Visual Studio main menu select View gt Solution Explorer to open Solution Explorer Right click on the project that will use AddEmail and select Add Reference from the pop up menu Click COM tab find and select AddEmail 3 0 Type Library click Select button then OK button 2 Declare variable that will hold a reference to the SmtpMail object Dim objSmtpMail As AddEmailLib SmtpMailClass 3a Create an instance of the SmtpMail object objSmtpMail New AddEmailLib SmtpMailClass 3b If you are sending e mails asynchronously you will need to access the same SmtpMail object on more than one page In this case store an instance of the SmtpMail object in Session collecti
96. om C HRESULT get_MessagelId BSTR HRESULT put_MessagelId BSTR spMailMessage gt PutMessageld 123456abc myisp com Remarks Messageld is globally unique ID of e mail message Default value of Messageld property is empty string In most cases application should not specify ID of the message because it will be assigned by AddEmail or by the outgoing mail server MessageBodyFile Property MessageBodyFile property specifies filename of the file that contains main body of e mail message Syntax Visual Basic objMailMessage MessageBodyFile test html VBScript objMailMessage MessageBodyFile test html C objMailMessage MessageBodyFile test html C HRESULT get_MessageBodyFile BSTR HRESULT put_MessageBodyFile BSTR spMailMessage gt PutMessageBodyFile test html Copyright c 2004 2010 Traysoft Inc All rights reserved 79 AddEmail 3 0 User Manual 3 2 15 3 2 16 Remarks Instead of supplying message body using MessageBody property application can set MessageBodyFile property to the filename of the file that contains the body AddEmail will read message body from the supplied file Please note that specified file is not loaded to memory immediately and must exist until the message is sent RequestReadReceipt Property RequestReadReceipt property specifies whether a read rec
97. on If IsNothing Session SmtpMail Then objSmtpMail New AddEmailLib SmtpMailClass Session SmtpMail ob jSmtpMail Else objSmtpMail Session SmtpMail End If 4 Set SMTP server address port username and password objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpPort 25 objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword 5a Send an e mail synchronously using SimpleSend or SimpleSendAttachment Dim strError As String Dim resultCode As Integer resultCode objSmtpMail SimpleSend jsmith myserver com jJane someserver com james someserver com test Test message strError If resultCode 0 Then E mail was sent successfully Else Send failed strError contains detailed error description End If 5b Alternatively create and fill MailMessage object and send it synchronously using Send or asynchronously using SendAsync Create message and setup subject and body Dim objMessage As New AddEmailLib MailMessageClass objMessage MessageSubject test objMessage MessageBody Test message Setup sender Dim objSender As New AddEmailLib MailAddressClass objSender Address jsmith myserver com objSender Name John Smith objMessage Sender objSender Setup first recipient Dim objRecipient As AddEmailLib MailAddressClass objRecipient New AddEmailLib MailAddressClass objRecipient Address jane someserver
98. ontain Unicode characters Unicode can be used in the body of a message in the subject field and in the names of sender and recipients SendAsync Sample Location AddEmail Samples C 2002 2003 SendAsync AddEmail Samples C 2005 201 0 SendAsync HtmIMail sample demonstrates how to send HTML e mails with attachments asynchronously using SendAsync This sample also shows how to process events from SmtpMail object Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 18 2 4 2 4 1 VB NET Using AddEmail in VB NET projects To use AddEmail in your Visual Basic NET project perform the following steps 1 Add a reference to the AddEmail library In Visual Studio main menu select Project gt Add Reference Click COM tab find and select AddEmail 3 0 Type Library click Select button then OK button 2 Declare variable that will hold a reference to the SmtpMail object and create an instance Dim WithEvents objSmtpMail As New AddEmailLib SmtpMailClass 3 Set SMTP server address port username and password objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpPort 25 objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword 4a Send an e mail synchronously using SimpleSend or SimpleSendAttachment Dim strError As String Dim resultCode As Integer resultCode objSmtpMail SimpleSend jsmith myserver com jJane someserver com james someserve
99. pMail 3 1 1 Overview SmtpMail object is used to send messages obtain status of messages cancel delivery of messages and set SMTP server parameters SmtpMail object should remain in memory until all messages are either delivered canceled or failed An application can create more than one instance of SmtpMail object if it needs to Syntax Visual Basic Dim objSmtpMail As New AddEmailLib SmtpMail objSmtpMail SmtpServer mail myisp com VBScript Dim objSmtpMail Set objSmtpMail CreateObject AddEmail SmtpMail objSmtpMail SmtpServer mail myisp com C AddEmailLib SmtpMailClass objSmtpMail new AddEmailLib SmtpMailClass objSmtpMail SmtpServer mail myisp com C AddEmailLib ISmtpMailPtr spSmtpMail spSmtpMail CreateInstance __uuidof AddEmailLib SmtpMail spSmtpMail gt PutSmtpServer mail myisp com Properties Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 44 SmtpServer Name or IP address of the SMTP server to use for sending e mail messages SmitpPort Port number on the SMTP server SmtpUsername User name account name on the SMTP server SmtpPassword Password on the SMTP server SmtpSSL Specifies whether SMTP server requires an encrypted connection TLS SSL SmtpSPA Specifies whether to use Secure Password Authentication SPA MaxThreads Maximum number of mail sending threads
100. ple Location AddEmail Samples VB6 HtmiMail HimiMail sample demonstrates how to send HTML e mails with attachments using Send This sample also shows how to set alternative text only body of e mail ImportHtm IWithImages Sample Location AddEmail Samples VB6 lmportHtm Withilmages ImportHtmlWithImages sample demonstrates how to import HTML file with embedded images using ImportHTML EmbeddedImages Sample Location AddEmail Samples VB6 Embedded images Embeddedimages sample demonstrates how to create and send HTML e mails with embedded images using Send EnterpriseMail Sample Location AddEmail Samples VB6 EnterpriseMail EnterpriseMail sample demonstrates features of AddEmail Enterprise version It shows how to queue and send multiple e mails simultaneously using AddEmail multi threading support This sample also shows how to process events from SmtpMail object In addition this sample also shows how to send e mails directly to recipients mail servers without using outgoing mail server of your organization or internet provider SendAsync Sample Location AddEmail Samples VB6 SendAsync HtmIMail sample demonstrates how to send HTML e mails with attachments asynchronously using SendAsync This sample also shows how to process events from SmtpMail object Copyright c 2004 2010 Traysoft Inc All rights reserved 15 AddEmail 3 0 User Manual 2 3 2 3 1 C Using AddEmail in C projects To use AddEmai
101. r in Specifies whether the message should be sent using SMTP server If the parameter is true not equal to zero message will be send using SMTP server specified in SmtpServer property If the parameter is false equal to zero message will be send directly to the recipients mail server s This parameter is valid for AddEmail Enterprise version only AddEmail Professional always uses specified SMTP server strError out Contains extended error information if the message failed to be sent empty string otherwise Return value Returns numeric result 0 if message was sent successfully 1 if connection to the server failed or in case of other Winsock errors gt 0 SMTP error code as defined in RFC 821 page 34 35 Remarks This method is synchronous it returns after the message was sent or after an error occuried Please use it with care because single threaded applications are blocked and can t process user input for the duration of Send call Please refer to SendAsync Method if you want to send messages without blocking your application Please refer to the SenderHostname topic for more information about sending e mails directly without using SMTP server of your organization or internet provider Enterprise version only Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 58 3 1 17 SendAsync Method SendAsync method sends e mail message asynchronously Syntax Visual Basic Fun
102. r and recipients SendAsync Sample Location AddEmail Samples ASP NET 1 x VB SendAsync AddEmail Samples ASP NET VB SendAsync SendAsync sample demonstrates how to send HTML e mails asynchronously using SendAsync This sample also shows how to get status of the e mail using GetStatus Delphi Using AddEmail in Delphi projects To use AddEmail in your Delphi project perform the following steps 1 Import AddEmail ActiveX control If you have Delphi 2005 or later In Delphi main menu select File gt New gt Package Delphi Win32 Save the package as AddEmail_Package using File gt Save As menu From Delphi main menu select Component gt Import Component Select Import ActiveX Control and click Next Find and select AddEmail 3 0 Type Library then click Add button Click Next make sure Palette Page is set to ActiveX and click Next Select Add unit to AddEmail_ Package project and click Finish In the Project Manager pane right click on AddEmail_Package and select Install Delphi should display a message confirming that the package is installed After that AddEmail will be installed to the ActiveX tab of Components palette If you have older version of Delphi In Delphi main menu select Components gt Import ActiveX Control Find and select AddEmail 3 0 Type Library then click Install button AddEmail ActiveX will be installed to the ActiveX tab of Components palette 2 Place SmtpMail object of AddEmail control on t
103. r com test Test message strError If resultCode 0 Then E mail was sent successfully Else Send failed strError contains detailed error description End If Ab Alternatively create and fill MailMessage object and send it synchronously using Send or asynchronously using SendAsync method Create message and setup subject and body Dim objMessage As New AddEmailLib MailMessageClass objMessage MessageSubject test objMessage MessageBody Test message Setup sender Dim objSender As New AddEmailLib MailAddressClass objSender Address jsmith myserver com objSender Name John Smith objMessage Sender objSender Setup first recipient Dim objRecipient As AddEmailLib MailAddressClass objRecipient New AddEmailLib MailAddressClass objRecipient Address jane someserver com objRecipient Name Jane Smith objMessage AddRecipient objRecipient Setup second recipient objRecipient New AddEmailLib MailAddressClass objRecipient Address james someserver com objRecipient Name James Smith objMessage AddRecipient objRecipient Copyright c 2004 2010 Traysoft Inc All rights reserved 19 AddEmail 3 0 User Manual 2 4 2 Send prepared message synchronously Dim strError As String Dim resultCode As Integer resultCode objSmtpMail Send objMessage True strError If resultCo
104. re us ascii US ASCII iso 8859 1 Western European ISO windows 1252 Western European Windows unicode Unicode internally converted to UTF 8 iso 8859 2 Central European ISO windows 1250 Central European Windows For more information please visit Charsets in Microsoft Internet Explorer 3 2 12 MessagePriority Property MessagePriority property specifies priority of e mail message Syntax Visual Basic objMailMessage MessagePriority MailPriorityHigh VBScript objMailMessage MessagePriority 1 MailPriorityHigh C objMailMessage MessagePriority AddEmailLib MailPriority MailPriorityHigh C HRESULT get_MessagePriority MailPriority HRESULT put_MessagePriority MailPriority spMailMessage gt PutMessagePriority AddEmailLib MailPriority Remarks MessagePriority property indicates priority of the message Possible priority values are defined in the MailPriority enumeration Default value of MessagePriority property is MailPriorityNormal Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 78 3 2 13 3 2 14 Messageld Property Messageld property specifies ID of e mail message Syntax Visual Basic objMailMessage Messageld 123456abc myisp com VBScript objMailMessage Messageld 12345 6abc myisp com C objMailMessage MessagelId 123456abc myisp c
105. ress Notifies of message sending progress Copyright c 2004 2010 Traysoft Inc All rights reserved 45 AddEmail 3 0 User Manual 3 1 2 SmtpServer Property SmtpServer property specifies name or IP address of the outgoing mail server SMTP server to use for sending e mail messages Syntax Visual Basic objSmtpMail SmtpServer mail myisp com VBScript objSmtpMail SmtpServer mail myisp com C objSmtpMail SmtpServer mail myisp com C HRESULT get_SmtpServer BSTR HRESULT put_SmtpServer BSTR spSmtpMail gt PutSmtpServer mail myisp com Remarks SmtpServer property can be empty if messages are to be sent directly without using outgoing mail server AddEmail Enterprise version only Please refer to Send Method SendAsync Method and EnterpriseMail sample for details SmtpPort Property SmtpPort property specifies port number on the outgoing mail server Syntax Visual Basic objSmtpMail SmtpPort 25 VBScript objSmtpMail SmtpPort 25 C objSmtpMail SmtpPort 25 C HRESULT get_SmtpPort LONG HRESULT put_SmtpPort LONG Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 46 spSmtpMail gt PutSmtpPort 25 Remarks Default value of SmtpPort property is 25 and doesn t have to be changed for most SMTP servers If port
106. rights reserved 59 AddEmail 3 0 User Manual 3 1 18 This method is asynchronous it validates the message places it to the message queue and returns immediately Actual sending of the message is done in another thread SendAsync doesn t block an application and can be safely used in single threaded applications The message number returned by this method is used in GetStatus Method GetErrorCode Method GetErrorDescription Method Cancel Method OnStatusChange Event and OnProgress Event Please refer to the SenderHostname topic for more information about sending e mails directly without using SMTP server of your organization or internet provider Enterprise version only GetStatus Method GetStatus method obtains status of a message that was queued for sending using SendAsync method Syntax Visual Basic Function GetStatus numMessageNumber As Long As AddEmailLib MailStatus Example Dim messageStatus As AddEmailLib MailStatus messageStatus objSmtpMail GetStatus numMessageNumber VBScript Function GetStatus numMessageNumber Example Dim messageStatus messageStatus objSmtpMail GetStatus numMessageNumber C AddEmailLib MailStatus GetStatus int numMessageNumber Example AddEmailLib MailStatus messageStatus objSmtpMail GetStatus numMessageNumber C HRESULT GetStatus LONG numMessageNumber MailStatus pmessageStatus Example AddEmailL
107. s Added ReplyTimeout property to specify how long AddEmail waits for a response from SMTP server before reporting timeout error Improved error reporting for socket errors and SMTP protocol errors Added checks for invalid symbols in e mail addresses Updated documentation and added new samples Version 2 1 1 Copyright c 2004 2010 Traysoft Inc All rights reserved AddEmail 3 0 User Manual 2 1 2 1 1 Added checks for proper format of sender s hostname when it s generated from computer name Fixed a bug that was causing InitializeSecurityContext error with some SSL TLS servers Version 2 1 Added ConnectAttempts property to specify number of times AddEmail tries to connect to the SMTP server before reporting connection error Added GetQueueSize method which returns number of e mails queued for sending Fixed a problem that prevented AddEmail from establishing SSL TLS connection to some SMTP servers such as smtp bizmail yahoo com and smtp att yahoo com Now AddEmail doesn t return timeout error if SMTP server takes a very long time to process an e mail with large attachments Added SetSender and SetReplyTo methods in order to support PowerBuilder 6 Version 2 0 2 Added support for custom From To and Cc headers Fixed a problem with text attachments in SimpleSendAttachment Version 2 0 1 Improved SSL TLS support Updated C 2005 VB NET 2005 and ASP NET 2 0 samples Sample
108. s Images from the web http or https links in HTML are not attached Please note that the current version of AddEmail does not import images specified in CSS using url values MailAttachment Overview MailAttachment object represents message attachment Syntax Visual Basic Dim objMailAttachment As New AddEmailLib MailAttachment objMailAttachment File c files document pdf VBScript Dim objMailAttachment Set objMailAttachment CreateObject AddEmail MailAttachment objMailAttachment File c files document pdf C Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 90 AddEmailLib MailAttachmentClass objMailAttachment new AddEmailLib MailAttachmentClass objMailAttachment File c files document pdf C AddEmailLib IMailAttachmentPtr spMailAttachment spMailAttachment CreateInstance __uuidof AddEmailLib MailAttachment spMailAttachment gt PutFile c files document pdf Properties File Filename of the attachment file Name Name of the attachment as it should appear in e mail message Encoding Encoding of the attachment ContentType Content type of the attachment Charset Character set of the attachment Inline Specifies whether the attachment is inline e g embedded in e mail message Contentld Content Id of the attachment Methods LoadFromMemory Load
109. s and Tutorials C MFC ATL Using AddEmail in C projects To use AddEmail in your C project perform the following steps 1 Import AddEmail type library add import directive to StdAfx h or other appropriate header import AddEmail AddEmail tlb named_guids 2 Declare variable that will hold a reference to the SmtpMail object private AddEmailLib ISmtpMailPtr m_spSmtpMail 3 Create an instance of the SmtpMail object m_spSmtpMail CreateInstance __uuidof AddEmailLib SmtpMail 4 Set SMTP server address port username and password m_spSmtpMail gt PutSmtpServer mail myserver com m_spSmtpMail gt PutSmtpPort 25 m_spSmtpMail gt PutSmtpUsername jsmith m_spSmtpMail gt PutSmtpPassword mypassword 5a Send an e mail synchronously using SimpleSend or SimpleSendAttachment Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 10 BSTR bstrError int resultCode m_spSmtpMail gt SimpleSend jsmith myserver com jJane someserver com james someserver com test Test message amp bstrError if resultCode 0 E mail was sent successfully else Send failed bstrError contains detailed error description 5b Alternatively create and fill MailMessage object and send it synchronously using Send or asynchronously using SendAsync Create message and setup subject and body A
110. s and subscribe to events private void OnStatusChange int messageNumber int newStatus Event processing code private void OnProgress int messageNumber int bytesSent int bytesTotal Event processing code Subscribe to events objSmtpMail OnStatusChange new _ISmtpMailEvents_OnStatusChangeEventHandler OnStatusChange objSmtpMail OnProgress new _ISmtpMailEvents_OnProgressEventHandler OnProgress Please refer to the Reference section of this manual for detailed description of AddEmail objects methods and properties Included C samples provide code snapshots for common operations such as sending text e mails sending HTML e mails adding attachments to e mails creating HTML e mails with embedded images Samples AddEmail includes the following C samples SimpleSend Sample Location AddEmail Samples C 2002 2003 SimpleSena AddEmail Samples C 2005 201 0 SimpleSena SimpleSend sample demonstrates how to send text or HTML e mails synchronously using SimpleSend SimpleSendAttachment Sample Copyright c 2004 2010 Traysoft Inc All rights reserved 17 AddEmail 3 0 User Manual Location AddEmail Samples C 2002 2003 SimpleSendAttachment AddEmail Samples C 2005 201 0 SimpleSendAttachment SimpleSendAttachment sample demonstrates how to send text or HTML e mails with attachments synchronously using SimpleSendAttachment HimIMail Sample
111. s attachment data from memory instead of file 3 3 2 File Property File property specifies filename including path of the attachment file Syntax Visual Basic objMailAttachment File c files document pdf VBScript objMailAttachment File c files document pdf C objMailAttachment File c files document pdf C HRESULT get_File BSTR HRESULT put_File BSTR spMailAttachment gt PutFile c files document pdf Copyright c 2004 2010 Traysoft Inc All rights reserved 91 AddEmail 3 0 User Manual Remarks Set File property to the full filename of the attachment AddEmail will read attachment from the specified file Please note that specified file is not loaded to memory immediately and must exist until the message is sent 3 3 3 Name Property Name property specifies name of the attachment as it should appear in the e mail Syntax Visual Basic objMailAttachment Name Report 2004 Pdf VBScript objMailAttachment Name Report 2004 Pdft C objMailAttachment Name Report 2004 Pdf C HRESULT get_Name BSTR HRESULT put_Name BSTR spMailAttachment gt PutName Report 2004 Pdf Remarks Default value of Name property is an empty string If Name is an empty string name part of the filename specified in the File property is used 3 3 4 Encoding Propert
112. s identified as the following files and all of the files can be found at the following location Traysoft AddEmail Redistr Files AddEmail dll COM DLL that contains all AddEmail objects AddEmail dll is a self registered COM DLL If you are using setup builder such as InstallShield or Wise Installation Studio simply add AddEmail dll to the setup project and mark AddEmail dll as Self register RegAddEmail bat Batch file for manual registration of AddEmail dil To register on a target computer copy AddEmail dil and RegAddEmail bat to the target computer then execute RegAddEmail bat On Windows Vista and Windows 7 please right click on RegAddEmail bat and select Run as Administrator then click Allow non Unicode AddEmail dll Alternative version of AddEmail dil for non Unicode versions of Windows 98 and Windows ME 9X DnsApi dll DNS library for Windows 95 98 ME AddEmail Enterprise version only Copy this file to Windows System32 folder NT4 DnsApi dll DNS library for Windows NT 4 0 AddEmail Enterprise version only Copy this file to Windows System32 folder 1 7 Version History Version 3 0 Full Windows 7 and Windows Server 2008 R2 support Added HTML import Now HTML emails with embedded images can be created automatically by importing HTML file from disk Added support for First LastName lt name domain com gt format to all SimpleSendXXX methods Added support for Unicode non ASCII attachment name
113. sing SimpleSend SimpleSendAttachment Sample Location AddEmail Samples VB NET 2002 2003 SimpleSendAttachment AddEmail Samples VB NET 2005 2010 SimpleSendAttachment SimpleSendAttachment sample demonstrates how to send text or HTML e mails with attachments synchronously using SimpleSendAttachment HimIMail Sample Location AddEmail Samples VB NET 2002 2003 HtmIMail AddEmail Samples VB NET 2005 201 0 Htm Mail Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 20 2 5 2 5 1 HtmlMail sample demonstrates how to send HTML e mails with attachments using Send This sample also shows how to set alternative text only body of e mail ImportHtm WithImages Sample Location AddEmail Samples VB NET 2002 2003 ImportHtm Withimages AddEmail Samples VB NET 2005 201 0 lmportHtm WithImages ImportHtmlWithImages sample demonstrates how to import HTML file with embedded images using ImportHTML EmbeddedImages Sample Location AddEmail Samples VB NET 2002 2003 Embeddedimages AddEmail Samples VB NET 2005 20 10 Embedded mages Embeddedimages sample demonstrates how to create and send HTML e mails with embedded images using Send EnterpriseMail Sample Location AddEmail Samples VB NET 2002 2003 EnterpriseMail AddEmail Samples VB NET 2005 201 0 EnterpriseMail EnterpriseMail sample demonstrates features of AddEmail Enterprise version It shows how to queue and send multiple e mails sim
114. sion only SenderHostname is used when AddEmail sends e mails directly without using SMTP server of your organization or internet provider Please see remarks for more information Syntax Visual Basic objSmtpMail SenderHostname myserver mydomain com VBScript objSmtpMail SenderHostname myserver mydomain com C objSmtpMail SenderHostname myserver mydomain com C HRESULT get_SenderHostname BSTR HRESULT put_SenderHostname BSTR spSmtpMail gt PutSenderHostname myserver mydomain com Remarks SenderHostname property should be set to the fully qualified hostname of the computer that sends e mail messages for example myserver mydomain com SenderHostname is transmitted to the recipient s mail server when AddEmail sends e mail messages directly Some mail servers do not accept incoming mail if SenderHostname is not set In addition some mail servers check reverse DNS entry for the IP address of the computer that sends e mail messages directly and verify that it matches with the SenderHostname Use the following link to check reverse DNS entry for an IP address http postmaster info aol com tools rdns htm SimpleSend Method SimpleSend method sends simple text or HTML e mail to one or more recipients synchronously Syntax Visual Basic Function SimpleSend strFrom As String strTo As String strSubject As String strMessage As String ByRef strError As S
115. ss objMailAddress Name Jane Smith objMailAddress Address jane someserver com objMailMessage AddRecipient objMailAddress Setup second recipient Set objMailAddress CreateObject AddEmail MailAddress objMailAddress Name James Smith objMailAddress Address james someserver com objMailMessage AddRecipient objMailAddress Send prepared messag numResultCode objSmtpMail SendScriptable objMailMessage True strError If numResultCode 0 Then MsgBox Sent successfully Else MsgBox strError End If Please refer to the Reference section of this manual for detailed description of AddEmail objects methods and properties Included VBScript samples provide code snapshots for common operations such as sending text e mails sending HTML e mails adding attachments to e mails Samples AddEmail includes the following VBScript samples SimpleSend Sample Location AddEmail Samples VBS SimpleSend vbs SimpleSend sample demonstrates how to send text or HTML e mails synchronously using SimpleSendScriptable SimpleSendAttachment Sample Location AddEmail Samples VBS SimpleSendAttachment vbs SimpleSendAttachment sample demonstrates how to send text or HTML e mails with attachments synchronously using SimpleSendAttachmentScriptable HimIMail Sample Location AddEmail Samples VBS Htm Mail vbs HtmIMail sample demonstrates how to send HTML e mails with attac
116. t Inline property to True for embedded images Please refer to the EmbeddedImages sample for details Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 94 3 3 8 3 3 9 Contentlid Property Contenitld property specifies ID of the embedded attachment ID is used to reference attachment in HTML body of e mail message Syntax Visual Basic objMailAttachment ContentId Imgi VBScript objMailAttachment ContentId Imgl C objMailAttachment ContentId Imgl C HRESULT get_ContentId BSTR HRESULT put_ContentId BSTR spMailAttachment gt PutContentId Img1 Remarks Default value of Contentld property is an empty string Application should set Contentld of the embedded attachments to be able to reference them in the HTML body of e mail message Please refer to the EmbeddedImages sample for details LoadFromMemory Method LoadFromMemory method loads attachment data from memory instead of file Syntax C HRESULT LoadFromMemory BYTE data LONG size Example BYTE data 100 fill data array spMailAttachment gt LoadFromMemory data 100 spMailAttachment gt PutName document pdf Parameters data in BYTE array with attachment data size in Copyright c 2004 2010 Traysoft Inc All rights reserved 95 AddEmail 3 0 User Manual 3 4 3 4 1 3 4 2 Siz
117. t PutAltMessageBody Testing testing testing Remarks AltMessageBody specifies alternative plain text version of HTML message AltMessageBody will be displayed if e mail client does not support HTML e mail messages Default value of AltMessageBody property is an empty string Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 76 3 2 10 AltMessageBodyEncoding Property 3 2 11 AltMessageBodyEncoding property specifies encoding of alternative plain text body of e mail message Syntax Visual Basic objMailMessage AltMessageBodyEncoding MailEncoding7Bit VBScript objMailMessage AltMessageBodyEncoding 1 MailEncoding7Bit C objMailMessage AltMessageBodyEncoding AddEmailLib MailEncoding MailEncoding7Bit C HRESULT get_AltMessageBodyEncoding MailEncoding HRESULT put_AltMessageBodyEncoding MailEncoding spMailMessage gt PutAltMessageBodyEncoding AddEmailLib MailEncoding7Bit Remarks AltMessageBodyEncoding property indicates which encoding method should be used for alternative plain text body of the message Possible encoding values are defined in the MailEncoding enumeration Default value of AltMessageBodyEncoding property is MailEncodingDefault which means that AddEmail will try to determine best encoding method based on the content of alternative message body App
118. t an e mail ClearAttachments Method ClearAttachments method clears list of attachments of e mail message Syntax Visual Basic Sub ClearAttachments Example objMailMessage ClearAttachments VBScript Sub ClearAttachments Example objMailMessage ClearAttachments C void ClearAttachments Example objMailMessage ClearAttachments C HRESULT ClearAttachments Example spMailMessage gt ClearAttachments Parameters None Return value None Remarks Use ClearAttachments method to remove all attachments from e mail message ClearRecipients Method ClearRecipients method clears list of recipients in To field of e mail message Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 86 Syntax Visual Basic Sub ClearRecipients Example objMailMessage ClearRecipients VBScript Sub ClearRecipients Example objMailMessage ClearRecipients C void ClearRecipients Example objMailMessage ClearRecipients C HRESULT ClearRecipients Example spMailMessage gt ClearRecipients Parameters None Return value None Remarks Use ClearRecipients method to remove all recipients from To field of e mail message Using this method you can clear list of recipients after sending and reuse prepared MailMessage object to send the same message to other recipients
119. t for the duration of the SimpleSend call Please refer to SendAsync Method if you want to send messages without blocking your application SerialNumber Property SerialNumber property specifies serial number to activate purchased copy of AddEmail Syntax Visual Basic objSmtpMail SerialNumber 12345 67890 ABCDE EFGH Copyright c 2004 2010 Traysoft Inc All rights reserved 55 AddEmail 3 0 User Manual VBScript objSmtpMail SerialNumber 12345 67890 ABCDE EFGH C objSmtpMail SerialNumber 12345 67890 ABCDE EFGH C HRESULT get_SerialNumber BSTR HRESULT put_SerialNumber BSTR spSmtpMail gt PutSerialNumber 12345 67890 ABCDE EFGH Remarks SerialNumber property contains an empty string by default After purchasing AddEmail you will receive serial number needed to activate AddEmail Set SerialNumber property to the serial number you received 3 1 14 ConnectAttempts Property ConnectAttempts specifies how many times AddEmail will try to connect to the outgoing mail server before returning connection error Syntax Visual Basic objSmtpMail ConnectAttempts 1 VBScript objSmtpMail ConnectAttempts 1 C objSmtpMail ConnectAttempts 1 C HRESULT get_ConnectAttempts LONG HRESULT put_ConnectAttempts LONG spSmtpMail gt
120. tesecdenceasbadsuaue sateussceesetesccersaeaspedseaneedzayeccedvanescs 39 13 Visual FOXP O ssroreoniunanenn i 39 Using AddEmail in FoxPro Projects ca iscccceccctecesccctetcecceecteesacceccntecdeencedscdeectereneesaccestegsddeyeecadveteesvaceteesucdexeefsedesseey 39 14 PowerBuilder sisinta nE iA RA EEEE SEAE AAA AANE 41 Using AddEmail in PowerBuilder projects csecssscsseeeseesseesseeesseneeenseeeeeneeeseaeeneeaseeeeasenseeesaeeaeseeesseeeeeesseeeene 41 Part Ill Reference 43 eat eda Ee D a E E T E E 43 ar R r a a 43 SmtpServer Property sennssnn n E Ea Aa aE AAE Kaaa a Ea AEE AAE aA AAE EAE Aa EE EE 45 SmtpPort Property siec ccc sececsseesvecs ccsectsgpctene cces deers secgiees cacvct cep cacneszes deeececeeshees eaevcteapvaeeescex dauececeniees EAEN iaraa a akdin inie 45 SmtpUsername Property w 46 SMtpPassword Property ssscssccessccssezcessecccces sche cevessccesacsscedvansssceoee sche setescodesiecstecssoueisenus scoeceiecocessieasbedesastecenveccuseeneccy 46 SMUPSSL Properly aere araa aerae aeaa AA a Aea EA EAE cudusgacuscussauevauesstobus suas ecdusenersbdarsaevent 47 SMUPSPA Property ssi ects sscei cs cesvearcececcse pene he cok cadets actions reana Adae ere dap N ARARA ri ESA aea Aapa ra Naua na RAAN EACE Edip No uaar ara iania 47 MaxThreads Property aicciccesecei seccticcceccecck cece dpcacde date ececeduenctecenaadeaievencvccetesdevedvensuacetcadediseandy sucterdevedbesdtecstanevauvecnareuen 48 SenderHostname Property ws 49 SimpleS
121. to create and send e mails that contain Unicode characters Unicode can be used in the body of a message in the subject field and in the names of sender and recipients SendAsync Sample Location AddEmail Samples ASP VBScript SendAsync SendAsync sample demonstrates how to send HTML e mails asynchronously using SendAsync method This sample also shows how to get status of the e mail using GetStatus ASP JScript Using AddEmail in ASP JScript projects To use AddEmail in your ASP JScript project perform the following steps 1 Optional If you are using Visual Interdev add a reference to the AddEmail library In Visual Interdev main menu select Project gt References Find and select AddEmail 3 0 Type Library 2 Declare variable that will hold a reference to the SmtpMail object var ob jSmtpMail 3a Create an instance of the SmtpMail object objSmtpMail Server CreateObject AddEmail SmtpMail 3b If you are sending e mails asynchronously you will need to access the same SmtpMail object on more than one page In this case store an instance of the SmtpMail object in Session collection if Session SmtpMail null objSmtpMail Server CreateObject AddEmail SmtpMail Session SmtpMail objSmtpMail else objSmtpMail Session SmtpMail 4 Set SMTP server address port username and password objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpPort 25 objSmtpM
122. to these patents trademarks copyrights or other intellectual property rights Copyright c 2004 2010 Traysoft Inc All rights reserved AddEmail 3 0 User Manual 1 5 1 6 System Requirements Operating Systems Supported operating systems are Microsoft Windows 7 all editions Microsoft Windows Vista all editions Microsoft Windows XP all editions Microsoft Windows 2008 Server editions Microsoft Windows 2003 Server editions Microsoft Windows 2000 Professional Workstation or Server Microsoft Windows Millennium Microsoft Windows 98 all editions Microsoft Windows NT Workstation or Server 4 0 service pack 6a Microsoft Windows 95 requires Winsock 2 0 update Development Environment AddEmail can be used with any development environment that supports COM ActiveX objects including Microsoft Visual Studio NET 2002 2003 2005 2008 and 2010 Microsoft Visual C 5 0 and 6 0 Microsoft Visual Basic 5 0 and 6 0 Microsoft Visual FoxPro Microsoft Visual J Microsoft Office 97 Office 2000 Office XP Office 2003 Office 2007 and Office 2010 ASP and ASP NET Borland C Builder Borland Delphi Sybase PowerBuilder Supported operating systems for development are e Microsoft Windows 7 all editions e Microsoft Windows Vista all editions e Microsoft Windows XP all editions e Microsoft Windows 2008 Server editions e Microsoft Windows 2003 Server editions e Microsoft Windows 2000
123. trFrom in Sender s e mail address You can also specify sender s name followed by the sender s e mail address in angled brackets strTo fin List of recipients e mail addresses separated by semicolon You can also specify recipient s name followed by the recipient s e mail address in angled brackets strSubject in Subject of the e mail message strMessage in Body of the e mail message Copyright c 2004 2010 Traysoft Inc All rights reserved 51 AddEmail 3 0 User Manual 3 1 11 strError out Contains extended error information if the message failed to be sent empty string otherwise Return value Returns numeric result 0 if the message was sent successfully 1 if connection to the server failed or in case of other Winsock errors gt 0 SMTP error code as defined in RFC 821 page 34 35 Remarks SimpleSend can be used to send text or HTML e mails Body of the e mail message should start with lt html gt tag for HTML e mail messages This method supports Unicode in the subject and body of the message as well as in the sender s and recipients names AddEmail will create Unicode e mail UTF 8 encoding if any part of the message contains Unicode characters This method is synchronous it returns after the message was sent or after an error occuried Please use it with care because single threaded applications are blocked and can t process user input for the duration of the SimpleSend call Pleas
124. tring As Long Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 50 Example Dim strError As String Dim numResultCode As Long numResultCode objSmtpMail SimpleSend My Name lt me myisp com gt Someone lt someone someisp com gt someoneelse someotherisp com test Test message strError VBScript Function SimpleSendScriptable strFrom strTo strSubject strMessage ByRef strError Example Dim strError Dim numResultCode numResultCode objSmtpMail SimpleSendScriptable My Name lt me myisp com gt Someone lt someone someisp com gt someoneelse someotherisp com test Test message strError C int SimpleSend string strFrom string strTo string strSubject string strMessage oul string strError Example string strError int numResultCode objSmtpMail SimpleSend My Name lt me myisp com gt Someone lt someone someisp com gt someoneelse someotherisp com test Test message out strError C HRESULT SimpleSend BSTR strFrom BSTR strTo BSTR strSubject BSTR strMessage BSTR ce I pstrError LONG pnumResultCode Example BSTR bstr int numResultCode spSmtpMail gt SimpleSend My Name lt me myisp com gt Someone lt someone someisp com gt someoneelse someotherisp com test Test message amp bstr _bstr_t strError bstr FALSE Parameters s
125. ts synchronously using Send method This sample also shows how to set alternative text only body of e mail SendAsync Sample Location AddEmail Samples Delphi 7 SendAsync SendAsync sample demonstrates how to send HTML e mails with attachments asynchronously using SendAsync method This sample also shows how to process events from SmitpMail object Visual FoxPro Using AddEmail in FoxPro projects AddEmail ActiveX can be used to send emails from Visual FoxPro applications To use AddEmail in your FoxPro project you need to add a code that creates SmtpMail object and sends a message using SimpleSend SimpleSendAttachment or Send Please use code snapshots below to get started Snapshot 1 simple text email PRIVATE objSmtpMail strError numResultCode objSmtpMail CREATEOBJECT AddEmail SmtpMail objSmtpMail SmtpServer mail myserver com objSmtpMail SmtpUsername jsmith objSmtpMail SmtpPassword mypassword strError numResultCode objSmtpMail SimpleSend jsmith myserver com jJane someserver com james someserver com test Test message strError IF numResultCode 0 THEN MESSAGEBOX Sent successfully Copyright c 2004 2010 Traysoft Inc All rights reserved Samples and Tutorials 40 ELSE MESSAGEBOX strError ENDIF Snapshot 2 text email with attachments PRIVATE objSmtpMail strError numResult
126. ultaneously using AddEmail multi threading support This sample also shows how to process events from SmtpMail object In addition this sample shows how to send e mails directly to recipients mail servers without using outgoing mail server of your organization or internet provider UnicodeMail Sample Location AddEmail Samples VB NET 2002 2003 UnicodeMail AddEmail Samples VB NET 2005 201 0 UnicodeMail UnicodeMail sample demonstrates how to create and send e mails that contain Unicode characters Unicode can be used in the body of a message in the subject field and in the names of sender and recipients SendAsync Sample Location AddEmail Samples VB NET 2002 2003 SendAsync AddEmail Samples VB NET 2005 2010 SendAsync HtmIMail sample demonstrates how to send HTML e mails with attachments asynchronously using SendAsync This sample also shows how to process events from SmtpMail object VBA Microsoft Office Using AddEmail in VBA projects AddEmail ActiveX can be used to send emails from any Microsoft Office application that supports Visual Basic for Applications VBA such as Microsoft Access Microsoft Excel Microsoft Word etc To use AddEmail in your VBA project perform the following steps Copyright c 2004 2010 Traysoft Inc All rights reserved 21 AddEmail 3 0 User Manual 1 Optional Add reference to AddEmail library In VBA editor menu select Tools gt References Find and select AddEmail 3 0
127. vers without using SMTP server of your organization or internet provider AddEmail Enterprise version only Developer Support Please visit Traysoft Developer Tools website at www traysoft com for the latest version of this manual You can also find additional samples news updates and other AddEmail related information on this website If you have any feedback or any questions please contact us or send an e mail to the following address We respond to all inquires within 1 2 business days e deviools traysoft com What s new in version 3 0 AddEmail ActiveX 3 0 adds several new features and improvements while maintaining complete compatibility with previous versions Source code written for AddEmail ActiveX 1 x and 2 x should compile and work with AddEmail ActiveX 3 0 without any modifications New features added to version 3 0 are listed below For a complete list of changes please refer to the Version History Windows 7 and Windows Server 2008 R2 compatibility AddEmail ActiveX 3 0 is fully compatible with all editions of Windows 7 and Windows Server 2008 R2 64 bit and 32 bit versions On 64 bit OS please use 32 bit version of regsvr32 to register AddEmail dll on the computer Run command prompt as an Administrator and type in c windows syswow64 regsvr32 c addemail addemail dll Copyright c 2004 2010 Traysoft Inc All rights reserved AddEmail 3 0 User Manual 1 3 assuming you copied AddEmail dll to C Ad
128. y Encoding property specifies encoding of the attachment Syntax Visual Basic Dim attachmentEncoding As AddEmailLib MailEncoding objMailAttachment Encoding MailEncoding7Bit VBScript Dim attachmentEncoding objMailAttachment Encoding 1 MailEncoding7Bit C Copyright c 2004 2010 Traysoft Inc All rights reserved Reference 92 3 3 5 3 3 6 objMailAttachment Encoding AddEmailLib MailEncoding MailEncoding7Bit C HRESULT get_Encoding MailEncoding HRESULT put_Encoding MailEncoding spMailAttachment gt PutEncoding AddEmailLib MailEncoding7Bit Remarks Encoding property indicates which encoding method should be used for the attachment Possible encoding values are defined in the MailEncoding enumeration Default value of Encoding property is MailEncodingBase64 and usually doesn t have to be changed Do not use encoding other than MailEncodingBase64 for binary files ContentType Property ContentType property specifies content type of the attachment Syntax Visual Basic objMailAttachment ContentType application pdf VBScript objMailAttachment ContentType application pdf C objMailAttachment ContentType application pdf C HRESULT get_ContentType BSTR HRESULT put_ContentType BSTR spMailAttachment
129. ync method Return value Returns numeric error code 0 if message was sent successfully 1 if connection to the server failed or in case of other Winsock errors gt 0 SMTP error code as defined in RFC 821 page 34 35 Remarks Copyright c 2004 2010 Traysoft Inc All rights reserved 61 AddEmail 3 0 User Manual 3 1 20 SendAsync method places a message into a message queue and returns message number which identifies the message If the message failed to be sent status of the message becomes MailStatusFailed and GetErrorCode method can be used to obtain error code GetErrorDescription Method GetErrorDescription method obtains error description for a message that was queued for sending using SendAsync method and failed to be sent Syntax Visual Basic Function GetErrorDescription numMessageNumber As Long As String Example Dim strError As String strError objSmtpMail GetErrorDescription numMessageNumber VBScript Function GetErrorDescription numMessageNumber Example Dim strError strError objSmtpMail GetErrorDescription numMessageNumber C string GetErrorDescription int numMessageNumber Example string strError objSmtpMail GetErrorDescription numMessageNumber C HRESULT GetErrorDescription LONG numMessageNumber BSTR pstrError Example _bstr_t strError spSmtpMail gt GetErrorDes
Download Pdf Manuals
Related Search
Related Contents
Apache Ant 1.5.4 Manual Air King 4TM64A/9515A User's Manual NextBase SDV47-AM ALCATEL Mobile Phones Cordless Telephone 200 User's Manual literature.rock...lautomation.com Installation Guide - Smart Security Systems Manual de Instruções Presentación de PowerPoint Toshiba PA3947U-1EAB stylus pen ICC IC107HDMWH wire connector Copyright © All rights reserved.
Failed to retrieve file