|
Persits
- ASPEmail
Send mail from your ASP pages
through our IMail System!
Here is some sample code for the
Persits object
to help you make the transition painlessly. The sample below
only works in VBScript in Classic ASP (ASP 3.0).
|
Persits object (VBScript - Classic ASP 3.0) |
| |
| Methods are
in blue. |
|
Properties are in red. |
| |
| Set Mail =
Server.CreateObject("Persits.MailSender") |
| Mail.Host = "mail.yourdomain.com" |
|
Mail.Username
= "emailaddress@yourdomain.com" |
|
Mail.Password
= "your password" |
|
Mail.From = "webmaster@yourdomain.com" |
| Mail.FromName = "Your
Name" |
|
Mail.AddAddress "recipient@somedomain.com" |
| Mail.AddCC "you@yourdomain.com" |
| Mail.Subject =
"Subject goes here" |
|
Mail.Body = "Message body goes here" |
|
On Error Resume Next |
|
Mail.SendToQueue |
| Set
Mail = Nothing |
| 'Note: A
username and password are only needed if you are on a |
| 'mail server
which requires authentication for mail relay. |
In ASP.Net using VB.Net, you would implement it only slightly differently.
|
Persits object (VB.NET using CreateObject) |
| |
| Methods are
in blue. |
|
Properties are in red. |
| |
| Dim
Mail as Object |
| Mail =
Server.CreateObject("Persits.MailSender") |
| Mail.Host = "mail.yourdomain.com" |
|
Mail.Username
= "emailaddress@yourdomain.com" |
|
Mail.Password
= "your password" |
|
Mail.From = "webmaster@yourdomain.com" |
| Mail.FromName = "Your
Name" |
|
Mail.AddAddress("recipient@somedomain.com") |
| Mail.AddCC("you@yourdomain.com") |
| Mail.Subject =
"Subject goes here" |
|
Mail.Body = "Message body goes here" |
|
On Error Resume Next |
Mail.Queue=1
Mail.Send(Missing.Value) |
| Mail =
Nothing |
|
'Note: A username and password are
only needed if you are on a |
|
'mail server which requires
authentication for mail relay. |
For the best performance in ASP.Net,
however, you would want to obtain your own copy of the Persits
ASPEmail component, and add it to the references in your .NET
source project. When compiled, an Interop DLL would be created
in your /bin folder which would allow you to declare and access
the object directly in .NET using COM marshalling. Below is an
example of how you would implement the code.
|
Persits object (VB.NET using Interop DLL) |
| |
| Methods are
in blue. |
|
Properties are in red. |
| |
| Dim
Mail as New ASPEMAILLib.MailSender() |
| Mail.Host
= "mail.yourdomain.com" |
|
Mail.Username =
"emailaddress@yourdomain.com" |
|
Mail.Password = "your password" |
|
Mail.From = "webmaster@yourdomain.com" |
| Mail.FromName = "Your
Name" |
|
Mail.AddAddress("recipient@somedomain.com") |
| Mail.AddCC("you@yourdomain.com") |
| Mail.Subject =
"Subject goes here" |
|
Mail.Body = "Message body goes here" |
|
On Error Resume Next |
Mail.Queue=1
Mail.Send(Missing.Value) |
| Mail =
Nothing |
|
'Note: A username and password are
only needed if you are on a |
|
'mail server which requires
authentication for mail relay. |
|
Persits object (C#.NET using Interop DLL) |
| |
| Methods are
in blue. |
|
Properties are in red. |
| |
|
using
System;
using
System.Web;
using ASPEMAILLib;
//....
try
{
ASPEMAILLib.MailSender Mail = (MailSender)
HttpContext.Current.Server.CreateObject("Persits.MailSender");
Mail.Host =
"mail.yourdomain.com";
Mail.Username =
"emailaddress@yourdomain.com"
Mail.Password = "your password"
//only required for
mail servers which require authentication
Mail.From =
"webmaster@yourdomain.com";
Mail.FromName =
"Your Name";
Mail.AddAddress("recipient@somedomain.com");
Mail.Subject = ""Subject
goes here";
Mail.Body =
"Message body goes here";
Mail.Queue=1
Mail.Send(Missing.Value);
Mail =
null;
}
catch
(Exception e) {
// Error handling code goes here
}
|
|
|
You can get the complete
documentation for all methods and properties at Persits
Website. ASPwebhosting.com
makes no warranty or representation with respect to this
information, its quality or suitability for a particular use or
purpose. This information is provided AS IS and the user assumes
ALL RISKS associated with its use.
ASPwebhosting.com will not be liable for direct, indirect or
consequential damages resulting from any defect in this
information or from use thereof.
ASPwebhosting.com shall assume no liability for any other
information programs or data used with or in conjunction with this
information, including the cost of recovering information,
programs or data.
|