Example CDOSYS Code - ASP Email

To send email via ASP you can use the following example code.

Note:

If you do not wish to enable smtp authentication, you must use the following mail server hostname/port in your code: 'pleskmail.interlayer.net' on port 587.

If you wish to use your domain (mail.domain.com) as the mail hostname, you must create a local email account and enable SMTP authentication in your code as shown below.


<%
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")

'This section provides the configuration information for the remote SMTP server.

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.yoursite.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password.
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="somemail@yourserver.com"
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword"

ObjSendMail.Configuration.Fields.Update

'End remote SMTP server configuration section==

ObjSendMail.To = "someone@someone.net"
ObjSendMail.Subject = "this is the subject"
ObjSendMail.From = "someone@someone.net"

' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"

ObjSendMail.Send

Set ObjSendMail = Nothing
%>

  • 1342 Users Found This Useful
Was this answer helpful?

Related Articles

403 Error - Forbidden: Access is denied

If you're receiving a 403 error under your Plesk site there are generally two reasons for this to...

How to connect remotely with SQL Server Management Studio

To connect with SQL Server Management Studio you just need to enter your domain name (if it's...

WordPress asking for FTP details

Under normal use WordPress should not require FTP to install plugins or apply updates. If your...

Plesk AWStats Errors

If you receive errors while viewing your stats, please check that Perl is enabled under your...

Plesk Email Settings

Generic Email Client SettingsThese are example settings and should work for any email client or...