Knowledgebase

How to send email from classic asp / CDOSYS /

<%
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@yoursite.com"
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword"
' replace somemail@yoursite.com  with a real email account that you created in websitepanel 
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.com"

' 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 
%>



Carbon Copy
ObjSendMail.CC = "user@somedomain.com"

Blind Carbon Copy
ObjSendMail.BCC = "user@somedomain.com"

Send Attachment (we hard code it here, but you could specify the file path using Server.Mappath as well)
ObjSendMail
.AddAttachment "c:\myweb\somefile.jpg"

Was this answer helpful?

 Print this Article

Also Read

Connecting to a SQL Server or MySQL Database in WebMatrix

Connecting to a SQL Server or MySQL Database in WebMatrix WebMatrix includes SQL Server Compact,...

Conection String to MS SQL 2008 DB - example

In order to connect to SQL Server 2008 from Management Studio, Enterprise Manager, Query...

How to configure web deploy/ webmatrix?

How to configure Web deploy & Webmatrix in WebsitePanel First log in WebsitePanel, navigate...

How to change asp.net version for my website?

1. Login to your control panel https://cp.aspnethosting.co.uk and click on Web - Web sites menu...

What will happen if I hit the memory limit?

If the worker process exceeds the private memory quota, IIS will recycle that pool which limits...