Extra mail header with CDO from .asp side - how to do this

M

majlandt

I have the below function witch I use to send mail to reciptents on my
maillist from an .asp side
I am about to make a bounce back system - and would therefore like to
make one extra MailHeader witch my bounce back system can take out -
But I have no luck with adding the extra header

-----------------------------------------
Sub sendmail

'Dimension variables
Dim objCDOSYSCon, objCDOSYSMail

'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")

'Out going SMTP server
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver")
= "localhost"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")
= 60

' Here I would like to include a extra header with the userID value -
but the below code don´t work.

'
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/mailheader:UserID")
= UserIDValue

objCDOSYSCon.Fields.Update

'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon


objCDOSYSMail.From = from
objCDOSYSMail.To = email
objCDOSYSMail.cc = emailcc
objCDOSYSMail.bcc = emailbcc
objCDOSYSMail.ReplyTo = ReplyTo

objCDOSYSMail.Subject = Subject

objCDOSYSMail.HTMLBody = Txt

objCDOSYSMail.Send

'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing

End Sub
 
A

Anthony Jones

I have the below function witch I use to send mail to reciptents on my
maillist from an .asp side
I am about to make a bounce back system - and would therefore like to
make one extra MailHeader witch my bounce back system can take out -
But I have no luck with adding the extra header

-----------------------------------------
Sub sendmail

'Dimension variables
Dim objCDOSYSCon, objCDOSYSMail

'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")

'Out going SMTP server
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserv
er")
= "localhost"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserv
erport")
= 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusin
g")
= 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconn
ectiontimeout")
= 60

' Here I would like to include a extra header with the userID value -
but the below code don´t work.

'
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/mailhead
er:UserID")
= UserIDValue

objCDOSYSCon.Fields.Update

'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon


objCDOSYSMail.From = from
objCDOSYSMail.To = email
objCDOSYSMail.cc = emailcc
objCDOSYSMail.bcc = emailbcc
objCDOSYSMail.ReplyTo = ReplyTo

objCDOSYSMail.Subject = Subject

objCDOSYSMail.HTMLBody = Txt

objCDOSYSMail.Send

'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing

End Sub
<<<<<<<<<<<<<<<<<<<<<

First don't try adding headers to the configuration object. Add them to the
message object fields collection.
Second always prefix your custom headers with 'x-' to avoid aliasing with
any other SMTP header and it's probably best to use an additional prefix is
you are using a common concept like userID.

E.G., x-mycompany-userid
 
M

majlandt

Anthony said:
I have the below function witch I use to send mail to reciptents on my
maillist from an .asp side
I am about to make a bounce back system - and would therefore like to
make one extra MailHeader witch my bounce back system can take out -
But I have no luck with adding the extra header

-----------------------------------------
Sub sendmail

'Dimension variables
Dim objCDOSYSCon, objCDOSYSMail

'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")

'Out going SMTP server
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserv
er")
= "localhost"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserv
erport")
= 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusin
g")
= 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconn
ectiontimeout")
= 60

' Here I would like to include a extra header with the userID value -
but the below code don´t work.

'
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/mailhead
er:UserID")
= UserIDValue

objCDOSYSCon.Fields.Update

'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon


objCDOSYSMail.From = from
objCDOSYSMail.To = email
objCDOSYSMail.cc = emailcc
objCDOSYSMail.bcc = emailbcc
objCDOSYSMail.ReplyTo = ReplyTo

objCDOSYSMail.Subject = Subject

objCDOSYSMail.HTMLBody = Txt

objCDOSYSMail.Send

'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing

End Sub
<<<<<<<<<<<<<<<<<<<<<

First don't try adding headers to the configuration object. Add them to the
message object fields collection.
Second always prefix your custom headers with 'x-' to avoid aliasing with
any other SMTP header and it's probably best to use an additional prefix is
you are using a common concept like userID.

E.G., x-mycompany-userid

ok, but how do I do that then
I dont know where to do that or how to do it
 
A

Anthony Jones

ok, but how do I do that then
I dont know where to do that or how to do it

You were pretty close:-

objCDOSYSMail.Fields("urn:schemas:mailheader:x-mycompany-userid") =
UserIDValue
objCDOSYSMail.Fields.Update
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top