Here's a simple Windows 2003 example that sends a text email. In this example, I constructed it as though I were grabbing information from a form submission:
Set myMail=CreateObject("CDO.Message")You can also send HTML formatted emails:
myMail.Subject = "Sending email with CDO"
myMail.From = "mymail@mydomain.com"
myMail.To = "someone@somedomain.com"
myMail.Bcc = "someoneelse@somedomain.com"
myMail.Cc = "someoneelse2@somedomain.com"
myMail.TextBody = "This is a message."
myMail.Send
set myMail=nothing
Set myMail=CreateObject("CDO.Message")You can send both a text version and an HTML versions
myMail.Subject = "Sending email with CDO"
myMail.From = "mymail@mydomain.com"
myMail.To = "someone@somedomain.com"
myMail.HTMLBody = "<h1>This is a message.</h1>"
myMail.Send
set myMail = nothing
Set myMail=CreateObject("CDO.Message")You can include CCs and BCCs:
myMail.Subject ="Sending email with CDO"
myMail.From ="mymail@mydomain.com"
myMail.To ="someone@somedomain.com"
myMail.HTMLBody = "<h1>This is a message.</h1>"
myMail.TextBody ="This is a message."
myMail.Send
set myMail=nothing
Set myMail=CreateObject("CDO.Message")You can easily mail a web page:
myMail.Subject = "Sending email with CDO"
myMail.From = "mymail@mydomain.com"
myMail.To = "someone@somedomain.com"
myMail.Bcc = "someoneelse@somedomain.com"
myMail.Cc = "someoneelse2@somedomain.com"
myMail.TextBody = "This is a message."
myMail.HTMLBody = "<h1>This is a message.</h1>"
myMail.Send
set myMail=nothing
Set myMail=CreateObject("CDO.Message")You can send an HTML file:
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.CreateMHTMLBody "http://www.w3schools.com/asp/"
myMail.Send
set myMail=nothing
Set myMail=CreateObject("CDO.Message")And you can send a mail with an attachment
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.CreateMHTMLBody "file://c:/inetpub/wwwroot/mywebsite/test.htm"
myMail.Send
set myMail=nothing
Set myMail=CreateObject("CDO.Message")It's not to difficult to have a form that passes the values to your mail object.
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="This is a message."
myMail.AddAttachment "c:\inetpub\wwwroot\mywebsite\test.txt"
myMail.Send
set myMail=nothing
Tip:
Use a properly formatted return address. Many spam filters these days will automatically block emails that don't have a return address. Some block emails where the return address isn't a real address as well.
1 comment:
hi. you said in the post: "How to Send Email in ASP from Windows Server 2003" that "It's not to difficult to have a form that passes the values to your mail object."
I have been trying to figure out how to pass the information from a form to one of these asp emails. could you please enlighten me?
iaincohn@comcast.net
thank you
Post a Comment