ASP Email With Attachments Failure using CDO.Message

N

Naveen Jain

Hi All,

I'm using this code to send a e-mail with attachment:

Dim oCdoMail
Set oCdoMail = Server.CreateObject("CDO.Message")
oCdoMail.From = strFromEmail
oCdoMail.To = strToEmail
oCdoMail.Subject = "Job Information"
oCdoMail.TextBody = "This is the email notification"
oCdoMail.AddAttachment strFileName
oCdoMail.Configuration.Fields.Item=2
oCdoMail.Configuration.Fields.Item=<My mail server IP>
oCdoMail.Send

This code scuccessfully send mail with attchment on my local. But when we
uplaod this code to the web server this is forceing error. If i mark comment
the folowing code
"oCdoMail.AddAttachment strFileName" this will work fine on the server, but
i need to send e-mail with attachments. how it could be possible ?

Please help me and suggest the way ASAP.
Thanks in Advance

Naveen Jain
OTS Solutions Pvt. Ltd.,
Guraon (India)
 
A

Anthony Jones

Naveen Jain said:
Hi All,

I'm using this code to send a e-mail with attachment:

Dim oCdoMail
Set oCdoMail = Server.CreateObject("CDO.Message")
oCdoMail.From = strFromEmail
oCdoMail.To = strToEmail
oCdoMail.Subject = "Job Information"
oCdoMail.TextBody = "This is the email notification"
oCdoMail.AddAttachment strFileName
oCdoMail.Configuration.Fields.Item=2
oCdoMail.Configuration.Fields.Item=<My mail server IP>
oCdoMail.Send

This code scuccessfully send mail with attchment on my local. But when we
uplaod this code to the web server this is forceing error. If i mark comment
the folowing code
"oCdoMail.AddAttachment strFileName" this will work fine on the server, but
i need to send e-mail with attachments. how it could be possible ?

Please help me and suggest the way ASAP.

It would help if you tolds what error you are getting?

Also how does this manage to work at all:-

oCdoMail.Configuration.Fields.Item=2
oCdoMail.Configuration.Fields.Item=<My mail server IP>

I suspect you meant:-

oCdoMail.Configuration.Fields.Item=2
oCdoMail.Configuration.Fields.Item=<My mail server IP>

With oCdoMail.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = IP
address
.Update ' You had this missing as well
End With

Also did you change the IP address to something the Web server can access?
Does the Web server not already have the configuration set correctly to send
emails?
Consider creating your own instance of the Configuration object like this:-

Dim oConf : Set oConf = Server.CreateObject("CDO.Configuration")

With oConf .Configuration
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = IP
address
.Update
End With

Set oCdoMail.Configuration = oConf

This avoids any conflicting values in the default configuration messing up
what you are trying to do.
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top