Creating an Instance of the AspEmail Object
To use AspEmail in an ASP environment, you must create an instance of the AspEmail object in your ASP script as follows:
To use AspEmail in a VB environment, open your VB project, go to Project/References... and check the box next to Persits Software AspEmail 5.0. Declare an AspEmail object variable as follows:
Dim Mail As MailSender
Create an instance of the AspEmail object as follows:
Set Mail = New MailSender
AspEmail comes with an ASP.NET wrapper assembly, ASPEMAILLib.dll, which has to be placed in the \Bin subdirectory of your ASP.NET application. Alternatively, you can place this file in the Global Assembly Cache.
In C#, create an instance of AspEmail as follows:
<%@ Import Namespace="ASPEMAILLib" %>
In order to send email, AspEmail "talks" to an SMTP server. The SMTP server does not have to be running on the same machine as AspEmail, in fact it can be located anywhere on the local network or the Internet.
You must specify the address of your SMTP server via the Host property. The default port number for SMTP services is 25, but if your SMTP server runs on a different port, you must also specify it via the Port property:
Mail.Host = "smtp.mycompany.com" ' Required
You may also specify a comma- or semicolon-separated list of SMTP hosts, as follows:
Mail.Host = "smtp.domain1.com;smtp2.domain1.com;host.domain2.com"
If the first host on the list is down, AspEmail will automatically attempt to connect to the second host, etc. If none of the specified hosts are working, an error exception will be thrown.
You must also specify the sender's email address and, optionally, name as follows:
Mail.From = "firstname.lastname@example.org" ' Required
To add message recipients, CCs, BCCs, and Reply-To's, use the AddAddress, AddCC, AddBcc and AddReplyTo methods, respectively. These methods accept two parameters: the email address and, optionally, name. Notice that you must not use an '=' sign to pass values to the methods. For example,
Mail.AddAddress "email@example.com", "John Smith"
Use the Subject and Body properties to specify the message subject and body text, respectively. A body can be in a text or HTML format. In the latter case, you must also set the IsHTML property to True. For example,
To send a file attachment with a message, use the AddAttachment method. It accepts the full path to a file being attached. Call this method as many times as you have attachments. Notice that you must not use the '=' sign to pass a value to the method:
To send a message, call the Send method. The method throws exceptions in case of an error. You may choose to handle them by using the On Error Resume Next statement, as follows:
On Error Resume Next
The following code sample demonstrates a simple email-sending form.
Click the links below to run this code sample (ASP and ASP.NET versions, respectively):
The following code sample sends email in the HTML format. The script is essentially the same except that the message body is set to an HTML string, and the property IsHTML is set to True:
Click the links below to run this code sample.
Instruciones completas con manual
Contáctenos por teléfono al (011) 4343-5880 o por email firstname.lastname@example.org