Send E-Mail from web service

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MIchele

    Send E-Mail from web service

    Hi,
    I need to send a mail message from a web service.
    If i execute the code from Windows Form Application the message is sended
    correctly but if i execute the same code from a web service an exception is
    throwed "Could not access 'CDO.Message' object".

    That's the code:

    Public Sub Send()
    Try
    Dim i As String
    Dim m As New MailMessage
    m.BodyEncoding = System.Text.Enc oding.UTF8
    m.BodyFormat = MailFormat.Html
    m.Priority = MailPriority.No rmal

    m.Subject = "Hello"
    m.To = "user1@company. com"
    m.From = "user2@company. com"
    m.Body = "Hello world"
    Dim ss As SmtpMail
    ss.SmtpServer = "mail.company.c om"
    ss.Send(m)
    Catch ex As Exception
    Debug.Write("Er ror: " & ex.Message)
    End Try
    End Sub

    Why? I need special permission? I miss something?

    Thanks
  • Kumar Shetgar

    #2
    RE: Send E-Mail from web service

    This is a generic error statement, so you really need to look into the details.
    Best thing would be to see what the inner exceptions contains.

    It may or may not be a permissions issue. Make sure you have valid SMTP server
    Check the below group discussions which solved my problem earlier...hope
    this will work for you too.
    Choosing the right web hosting company is one of the most important — and most consequential — decisions you’ll make when starting or growing your website.



    -- Kumar Shetgar

    "MIchele" wrote:
    [color=blue]
    > Hi,
    > I need to send a mail message from a web service.
    > If i execute the code from Windows Form Application the message is sended
    > correctly but if i execute the same code from a web service an exception is
    > throwed "Could not access 'CDO.Message' object".
    >
    > That's the code:
    >
    > Public Sub Send()
    > Try
    > Dim i As String
    > Dim m As New MailMessage
    > m.BodyEncoding = System.Text.Enc oding.UTF8
    > m.BodyFormat = MailFormat.Html
    > m.Priority = MailPriority.No rmal
    >
    > m.Subject = "Hello"
    > m.To = "user1@company. com"
    > m.From = "user2@company. com"
    > m.Body = "Hello world"
    > Dim ss As SmtpMail
    > ss.SmtpServer = "mail.company.c om"
    > ss.Send(m)
    > Catch ex As Exception
    > Debug.Write("Er ror: " & ex.Message)
    > End Try
    > End Sub
    >
    > Why? I need special permission? I miss something?
    >
    > Thanks[/color]

    Comment

    Working...