简体   繁体   中英

CDOSys vs SMTPsvg.Mailer

I've the following classic ASP code to send email using SMTPsvg.Mailer :

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName   = "From Name"
Mailer.FromAddress= "someone@test.com"
Mailer.RemoteHost = "mail.test.com"
Mailer.AddRecipient "inquiry", "test@test.com"
Mailer.Subject    = "Contact Request"

I'm trying to convert it to use CDOsys, but the CDOsys object doesn't seem to have FromName, RemoteHost attributes as per the documentation here:

http://msdn.microsoft.com/en-us/library/ms526367(v=exchg.10).aspx

Is it possible that the remote host is automatically included when using CDOsys ?

For the from address you can specify a from name and address using the "From" property, like this:

myMail.From="""Sender Name"" <email@sender.com>"

Note that the name is enclosed in double quotes.

If you don't specify a mail server, CDOSYS uses the default server (localhost, port 25). To specify a different server you need to use ConfigurationFields, like this:

myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.server.com"
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
myMail.Configuration.Fields.Update

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM