habs_2005
asked on
cdo - windows 2000 - adding message headers
I have been trying to change the following in cdo - return-path, and add message header. When I use the following code I end up with 2 different return-paths and a header is not added.
Dim objCfg
set objCfg = server.CreateObject("CDO.C onfigurati on")
Dim objCfgFlds
set objCfgFlds = objCfg.Fields
with objCfgFlds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.item(cdoSMTPServerPort) = 8025
.Item(cdoSMTPServer) = "127.0.0.1"
.Item("urn:schemas:mailhea der:X-Mail er") = "Microsoft CDO testing change"
.item("urn:schemas:mailhea der:return -path") = "bounce@test.com"
.item("urn:schemas:mailhea der:sender ") = "nc@test.com"
.update
End with
response.Write(now())
response.Write(" it ends on ..")
Dim objMail
set objMail = server.CreateObject("CDO.M essage")
with objMail
.Configuration = objCfg .From = "natacha@onroad.com"
.To = "from@test.com"
.Subject = "Sample CDO Message"
.TextBody = "This is a test for CDO.message"
.Send
End with
Set objMail = nothing
Please point me in the right direction :)
Dim objCfg
set objCfg = server.CreateObject("CDO.C
Dim objCfgFlds
set objCfgFlds = objCfg.Fields
with objCfgFlds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.item(cdoSMTPServerPort) = 8025
.Item(cdoSMTPServer) = "127.0.0.1"
.Item("urn:schemas:mailhea
.item("urn:schemas:mailhea
.item("urn:schemas:mailhea
.update
End with
response.Write(now())
response.Write(" it ends on ..")
Dim objMail
set objMail = server.CreateObject("CDO.M
with objMail
.Configuration = objCfg .From = "natacha@onroad.com"
.To = "from@test.com"
.Subject = "Sample CDO Message"
.TextBody = "This is a test for CDO.message"
.Send
End with
Set objMail = nothing
Please point me in the right direction :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ideally you should modify the above subroutine to take in the additional parameters required for the custom headers. So that you can reuse the subroutine throughout your code..
Cheers!!
Cheers!!
ASKER
Thanks for the solutions - I just have a few more questions before I accept an answer.
ap_sajith - I have copied your code and tested it on my local server. It does change the header and I can create a new customer header as well. The only strange thing that is does is creates 2 return-paths - the first one set is the sender and the second one is the one I tried to set. Any idea why this might happen?
Also - is there a reason you use the following format:
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServer
instead of .Fields(cdoSMTPServer) = sMailServer
Thanks again!!
ap_sajith - I have copied your code and tested it on my local server. It does change the header and I can create a new customer header as well. The only strange thing that is does is creates 2 return-paths - the first one set is the sender and the second one is the one I tried to set. Any idea why this might happen?
Also - is there a reason you use the following format:
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServer
instead of .Fields(cdoSMTPServer) = sMailServer
Thanks again!!
>>The only strange thing that is does is creates 2 return-paths - the first one set is the sender and the second one is the one I tried to set. Any idea why this might happen?<<
I did try it at my side and it was returning just one return path. Maybe it is some setting in your mail server.
As for using
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServer
instead of .Fields(cdoSMTPServer) = sMailServer,
I do not have the CDO typelyb included. So i will have to do away with the CDO constants.
Cheers!!
I did try it at my side and it was returning just one return path. Maybe it is some setting in your mail server.
As for using
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServer
instead of .Fields(cdoSMTPServer) = sMailServer,
I do not have the CDO typelyb included. So i will have to do away with the CDO constants.
Cheers!!
ASKER
Thanks again ap_sajith !!
I will have to speak to our sys admin - we are just using the smtp server in windows 2000. Hopefully he can figure out what the problem with the return path might be.
I will have to speak to our sys admin - we are just using the smtp server in windows 2000. Hopefully he can figure out what the problem with the return path might be.
Grade B?. Any particular reason for a lower grade?.
Cheers!!
Cheers!!
Please let me know if there is any reason why you gave the solution a Grade of 'B'... Otherwise, i might have to ask one of th emoderators to review the grading.
Thanks!
Thanks!
ASKER
I gave a B because your answer did not solve my entire problem. If you want a moderator to review - please feel free. I cannot seem to change your grade myself.
Its ok... If you felt that my answer wasnt complete, then i must accept it... Thanks for the reply though.
Cheers!!
Cheers!!
' ** SUBROUTINE TO SEND EMAIL USING CDOSYS **
'**USAGE **
'strMailBody="<Font Color=Red><B>Test HTML String</B></Font>"
'CALL SendMailCDOSYS("a@b.com","
Sub SendMailCDOSYS(strFrom,str
On Error Resume Next
Dim objCDOConf,objCDOSYS
' ** CREATE THE E-MAIL SERVER OBJECT **
Set objCDOSYS = Server.CreateObject("CDO.M
Set objCDOConf = Server.CreateObject ("CDO.Configuration")
' ** SET AND UPDATE FIELDS PROPERTIES **
With objCDOConf
' ** OUT GOING SMTP SERVER **
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServer
' ** SMTP PORT **
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
' ** CDO PORT **
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
' ** TIMEOUT **
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Fields.Update
End With
' ** UPDATE THE CDOSYS CONFIGURATION **
Set objCDOSYS.Configuration = objCDOConf
With objCDOSYS
' ** WHO THE E-MAIL IS FROM **
.From = strFrom
' ** WHO THE E-MAIL IS SENT TO **
.To = strTo
' ** THE SUBJECT OF THE E-MAIL **
.Subject = strSubject
' ** SET THE E-MAIL BODY FORMAT (HTMLBody=HTML TextBody=Plain) **
If blnHTML = True Then
.HTMLBody = strMailBody
Else
.TextBody = strMailBody
End If
' ** SEND THE E-MAIL **
.Send
End with
' ** CLOSE THE SERVER MAIL OBJECT **
Set objCDOSYS = Nothing
End Sub