Introduction
absoluteTools - SendMail is a Com Activex Object created to help sending email from Windows-based applications, using any Com-aware programming language, like Visual Basic, Visual C++ or Delphi. The usage is very simple as shown by the supplied VB example project.
The trial version downloaded from the website http://www.abspdf.com is fully functional with a limit of 60-days of free evaluation and a text added to subject and body of the email. To remove the "Evaluation" text and use the control beyond the 60-days trial period just register the object by providing a valid license code.
To obtain a license code visit http://www.abspdf.com.
ACTIVEX COM VERSION
Getting started
Register the control
First you need to register the control. Open a "Command Prompt" window, go to the folder where you unpacked the files and type: regsvr32 absTools-SendMail.dll
To use the control in Visual Basic
Create a new project. See Demo.vbp as an example.
- From menu: Project -> References...
Check 'absTools - SendMail'
- Create object:
Dim objMyControl As Object Set objMyControl = CreateObject("absTools-SendMail")
- Unlock the control (if you have a valid key, otherwise just skip to the next item):
retVal = objMyControl.Unlock("Name", "MyCompany", "unlock_key")
- Init the control with the SMTP server (usually ISP dependent, ask your Internet provider for a valid value for this field):
retVal = objMyControl.Init("192.168.254.10")
- Set sender address:
retVal = objMyControl.SetSender("support@abspdf.com")
- Add recipient address (repeat for all the recipients):
retVal = objMyControl.AddRecipient("info@abspdf.com")
- Add attachment (repeat for all the attachments):
retVal = objMyControl.AddAttachment("D:\Data\file1.zip")
- Set subject, plain text and html text (just leave blank to set only plain text version) of the message:
retVal = objMyControl.SetMessage("Message subject", "Plain text message", "<html>HTML <i>text</i></html>")
- Send the message:
retVal = objMyControl.SendMail()
For each step you can test retVal to see if there was an error: if retVal is empty the action succeeded, otherwise you get a text string representing the error (see later for details).
Usage
Library absTools - SendMail
absTools-SendMail
Methods
Function AddAttachment(file_fullpath As String) As String
Add attachment to the attachment list. Preferably use full path to the file. Repeat for each file to be attached to the message. Returns:
- <empty string>: ok - "ERROR_INVALID_ATTACHMENT": file doesn't exist or isn't readable
Function AddInlineImage(file_fullpath As String) As String
Add inline image to the email. Use images with different names, then use those names in the HTML part of the message, and the control will take care of linking them as needed (see sample in the distribution). A single inline images can be referenced many times in the HTML code. Repeat for inline imabe to be added to the message. Supported filetypes (use the right extension): jpeg, gif, png, tiff, bmp. Returns:
- <empty string>: ok - "ERROR_UNSUPPORTED_INLINE_FILE_TYPE": the filetype isn't supported - "ERROR_INVALID_INLINE_IMAGE": file doesn't exist or isn't readable
Function AddBcc(address As String) As String
Add recipient address to the Bcc (blind carbon copy) list. Use either the form "john.smith@mail.com" or "John Smith <john.smith@mail.com>". Repeat for each recipient.
Returns:
- <empty string>: ok - "ERROR_INVALID_BCC_EMAIL": recipient email is invalid
Function AddCC(address As String) As String
Add recipient address to the CC (carbon copy) list. Use either the form "john.smith@mail.com" or "John Smith <john.smith@mail.com>". Repeat for each recipient.
Returns:
- <empty string>: ok - "ERROR_INVALID_CC_EMAIL": recipient email is invalid
Function AddRecipient(address As String) As String
Add recipient address to the recipient list. Use either the form "john.smith@mail.com" or "John Smith <john.smith@mail.com>". Repeat for each recipient.
Returns:
- <empty string>: ok - "ERROR_INVALID_RECIPIENT_EMAIL": recipient email is invalid
Function ClearAttachments() As String
Clear attachments list. After Init the list is already empty.
Returns:
- <empty string>: ok
Function ClearAutoInlineImages() As String
Clear the auto inline images flag.
Returns:
- <empty string>: ok
Function ClearAutoScriptAndCSS() As String
Clear the auto inline scripts and css flag.
Returns:
- <empty string>: ok
Function ClearBcc() As String
Clear Bcc list. After Init the list is already empty.
Returns:
- <empty string>: ok
Function ClearCC() As String
Clear CC list. After Init the list is already empty.
Returns:
- <empty string>: ok
Function ClearInlineImages() As String
Clear inline images list. After Init the list is already empty.
Returns:
- <empty string>: ok
Function ClearRecipients() As String
Clear recipients list. After Init the list is already empty.
Returns:
- <empty string>: ok
Function Init(smtp_server As String) As String
Use this method first to set the SMTP server (usually ISP dependent, ask your Internet provider for a valid value for this field) and to reset all internal fields.
Returns:
- <empty string>: ok - "ERROR_INVALID_SMTP_SERVER": the SMTP server supplied is invalid
Function SendMail() As String
Send message with set parameters.
Returns:
- <empty string>: ok - "ERROR_ATTACHMENT_OPEN": one of the attachments couldn't be read - "ERROR_MAIL_SEND": there was an error sending mail, usually the SMTP server is invalid or either the sender or one of the recipients wasn't accepted by the server - "ERROR_INSUFFICIENT_DATA": one or more compulsory fields (recipient, sender, SMTP server) wasn't filled - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it
Function SetAutoInlineImages() As String
Set the auto inline images flag. The control automatically harvests and embeds in the email all local images referenced in the HTML.
Returns:
- <empty string>: ok
Function SetAutoScriptAndCSS() As String
Set the auto inline scripts and css flag. The control automatically harvests and embeds all local scripts (javascript, vbscript, etc) and css referenced in the HTML.
Returns:
- <empty string>: ok
Function SetMessage(subject As String, text_plain As String, text_html As String) As String
Set subject, plain text and html (leave blank if you want only the plain text version) to the message.
Returns:
- <empty string>: ok
Function SetMessageFromFile(subject As String, text_plain_fullpath As String, text_html_fullpath As String) As String
Set subject, plain text and html from external files to the message.
Returns:
- <empty string>: ok
- "ERROR_TEXT_FILE_OPEN": couldn't open the specified text file
- "ERROR_HTML_FILE_OPEN": couldn't open the specified html file
Function SetPort(port As String) As String
Set port for SMTP connection (default 25).
Returns:
- <empty string>: ok
Function SetReplyTo(address As String) As String
Set Reply-to address. Use either the form "john.smith@mail.com" or "John Smith <john.smith@mail.com>".
Returns:
- <empty string>: ok - "ERROR_INVALID_REPLYTO_EMAIL": address is invalid
Function SetSender(sender_address As String) As String
Set sender address. Use either the form "john.smith@mail.com" or "John Smith <john.smith@mail.com>".
Returns:
- <empty string>: ok - "ERROR_INVALID_SENDER_EMAIL": sender email is invalid
Function SetSmtpAuth(smtp_username As String, smtp_password As String) As String
Set username and password for SMTP authentication.
Returns:
- <empty string>: ok
Function Unlock(username As String, company As String, key As String) As String
Returns:
- <empty string>: ok - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match the version or the information supplied - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_UNREGISTERED_VERSION": the control is being used in free trial mode - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
.NET VERSION
Getting started (.NET)
Development and test environment
All samples have been created and tested under Microsoft .NET Framework Runtime 1.1 and developed using SharpDevelop, the excellent free IDE for C# and VB.NET (http://www.sharpdevelop.net/OpenSource/SD/). Be assured that the code is pure VB.NET (or C# if applicable), runs perfectly under MS .NET Framework and can be used in your Visual Studio .NET projects without any change.
Reference the Assembly
With the procedure specific to your development environment, reference the Assembly "absTools-SendMailNET.dll" in your project.
To use the control in VB.NET
Create a new project. Add a reference to the assembly "absTools-SendMailNET.dll" in your project.
- Create object:
Dim objMyControl As Object Set objMyControl = CreateObject("absTools-SendMail")
- Unlock the control (if you have a valid key, otherwise just skip to the next item):
retVal = objMyControl.Unlock("Name", "MyCompany", "unlock_key")
- Init the control with the SMTP server (usually ISP dependent, ask your Internet provider for a valid value for this field):
retVal = objMyControl.Init("192.168.254.10")
- Set sender address:
retVal = objMyControl.SetSender("support@abspdf.com")
- Add recipient address (repeat for all the recipients):
retVal = objMyControl.AddRecipient("info@abspdf.com")
- Add attachment (repeat for all the attachments):
retVal = objMyControl.AddAttachment("D:\Data\file1.zip")
- Set subject, plain text and html text (just leave blank to set only plain text version) of the message:
retVal = objMyControl.SetMessage("Message subject", "Plain text message", "<html>HTML <i>text</i></html>")
- Send the message:
retVal = objMyControl.SendMail()
For each step you can test retVal to see if there was an error: if retVal is empty the action succeeded, otherwise you get a text string representing the error (see later for details).
Usage (.NET)
Assembly absTools-SendMailNET
Namespace absTools
Type SendMailNET
Methods
Function AddAttachment(file_fullpath As String) As String
Add attachment to the attachment list. Preferably use full path to the file. Repeat for each file to be attached to the message. Returns:
- <empty string>: ok - "ERROR_INVALID_ATTACHMENT": file doesn't exist or isn't readable
Function AddInlineImage(file_fullpath As String) As String
Add inline image to the email. Use images with different names, then use those names in the HTML part of the message, and the control will take care of linking them as needed (see sample in the distribution). A single inline images can be referenced many times in the HTML code. Repeat for inline imabe to be added to the message. Supported filetypes (use the right extension): jpeg, gif, png, tiff, bmp. Returns:
- <empty string>: ok - "ERROR_UNSUPPORTED_INLINE_FILE_TYPE": the filetype isn't supported - "ERROR_INVALID_INLINE_IMAGE": file doesn't exist or isn't readable
Function AddBcc(address As String) As String
Add recipient address to the Bcc (blind carbon copy) list. Use either the form "john.smith@mail.com" or "John Smith <john.smith@mail.com>". Repeat for each recipient.
Returns:
- <empty string>: ok - "ERROR_INVALID_BCC_EMAIL": recipient email is invalid
Function AddCC(address As String) As String
Add recipient address to the CC (carbon copy) list. Use either the form "john.smith@mail.com" or "John Smith <john.smith@mail.com>". Repeat for each recipient.
Returns:
- <empty string>: ok - "ERROR_INVALID_CC_EMAIL": recipient email is invalid
Function AddRecipient(address As String) As String
Add recipient address to the recipient list. Use either the form "john.smith@mail.com" or "John Smith <john.smith@mail.com>". Repeat for each recipient.
Returns:
- <empty string>: ok - "ERROR_INVALID_RECIPIENT_EMAIL": recipient email is invalid
Function ClearAttachments() As String
Clear attachments list. After Init the list is already empty.
Returns:
- <empty string>: ok
Function ClearAutoInlineImages() As String
Clear the auto inline images flag.
Returns:
- <empty string>: ok
Function ClearAutoScriptAndCSS() As String
Clear the auto inline scripts and css flag.
Returns:
- <empty string>: ok
Function ClearBcc() As String
Clear Bcc list. After Init the list is already empty.
Returns:
- <empty string>: ok
Function ClearCC() As String
Clear CC list. After Init the list is already empty.
Returns:
- <empty string>: ok
Function ClearInlineImages() As String
Clear inline images list. After Init the list is already empty.
Returns:
- <empty string>: ok
Function ClearRecipients() As String
Clear recipients list. After Init the list is already empty.
Returns:
- <empty string>: ok
Function Init(smtp_server As String) As String
Use this method first to set the SMTP server (usually ISP dependent, ask your Internet provider for a valid value for this field) and to reset all internal fields.
Returns:
- <empty string>: ok - "ERROR_INVALID_SMTP_SERVER": the SMTP server supplied is invalid
Function SendMail() As String
Send message with set parameters.
Returns:
- <empty string>: ok - "ERROR_ATTACHMENT_OPEN": one of the attachments couldn't be read - "ERROR_MAIL_SEND": there was an error sending mail, usually the SMTP server is invalid or either the sender or one of the recipients wasn't accepted by the server - "ERROR_INSUFFICIENT_DATA": one or more compulsory fields (recipient, sender, SMTP server) wasn't filled - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it
Function SetAutoInlineImages() As String
Set the auto inline images flag. The control automatically harvests and embeds in the email all local images referenced in the HTML.
Returns:
- <empty string>: ok
Function SetAutoScriptAndCSS() As String
Set the auto inline scripts and css flag. The control automatically harvests and embeds all local scripts (javascript, vbscript, etc) and css referenced in the HTML.
Returns:
- <empty string>: ok
Function SetMessage(subject As String, text_plain As String, text_html As String) As String
Set subject, plain text and html (leave blank if you want only the plain text version) to the message.
Returns:
- <empty string>: ok
Function SetMessageFromFile(subject As String, text_plain_fullpath As String, text_html_fullpath As String) As String
Set subject, plain text and html from external files to the message.
Returns:
- <empty string>: ok
- "ERROR_TEXT_FILE_OPEN": couldn't open the specified text file
- "ERROR_HTML_FILE_OPEN": couldn't open the specified html file
Function SetReplyTo(address As String) As String
Set Reply-to address. Use either the form "john.smith@mail.com" or "John Smith <john.smith@mail.com>".
Returns:
- <empty string>: ok - "ERROR_INVALID_REPLYTO_EMAIL": address is invalid
Function SetSender(sender_address As String) As String
Set sender address. Use either the form "john.smith@mail.com" or "John Smith <john.smith@mail.com>".
Returns:
- <empty string>: ok - "ERROR_INVALID_SENDER_EMAIL": sender email is invalid
Function SetSmtpAuth(smtp_username As String, smtp_password As String) As String
Set username and password for SMTP authentication.
Returns:
- <empty string>: ok
Function Unlock(username As String, company As String, key As String) As String
Returns:
- <empty string>: ok - "ERROR_INCORRECT_KEY": the key isn't invalid or doesn't match the version or the information supplied - "ERROR_EXPIRED_EVALUATION": the evaluation 60-days period is over, please register the control to continue using it - "ERROR_UNREGISTERED_VERSION": the control is being used in free trial mode - "ERROR_TOO_MANY_KEY_GUESSES": a wrong activation code has been supplied too many times, please try again after 24 hours
Copyright
absoluteTools - SendMail is a Copyright 2004-2005 of the absolutePDF Team
All rights reserved.
The software is given "as is". No responsibility shall be assumed by the authors for loss or damage, whether real or consequential, arising from its use. By using the software you explicitly agree to hold the authors blameless for any such losses or damages.
Please visit http://www.abspdf.com for more information.
|