ASP Email With Attachments Failure using CDO.Message

Discussion in 'ASP General' started by Naveen Jain, Jul 17, 2006.

  1. Naveen Jain

    Naveen Jain Guest

    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)
    Naveen Jain, Jul 17, 2006
    #1
    1. Advertising

  2. "Naveen Jain" <> wrote in message
    news:...
    > 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.


    > Thanks in Advance
    >
    > Naveen Jain
    > OTS Solutions Pvt. Ltd.,
    > Guraon (India)
    >
    Anthony Jones, Jul 17, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Liz Patton
    Replies:
    4
    Views:
    5,589
    Liz Patton
    Jul 17, 2004
  2. Replies:
    0
    Views:
    289
  3. tabonni
    Replies:
    15
    Views:
    366
    Ray Costanzo [MVP]
    Sep 1, 2004
  4. Hugh Welford

    cdo message attachments

    Hugh Welford, Dec 15, 2004, in forum: ASP General
    Replies:
    0
    Views:
    108
    Hugh Welford
    Dec 15, 2004
  5. ThatsIT.com.au

    CDO.Message and attachments

    ThatsIT.com.au, Jan 22, 2007, in forum: ASP General
    Replies:
    0
    Views:
    137
    ThatsIT.com.au
    Jan 22, 2007
Loading...

Share This Page