Try this:
'----------------------------------------------------------
Try
Dim msg As New System.Net.Mail.MailMessage
Dim smtp As New System.Net.Mail.SmtpClient
Dim addrFrom As New System.Net.Mail.MailAddress("from@mail.com")
Dim addrTo As New System.Net.Mail.MailAddress("to@mail.com")
msg.From = addrFrom
msg.To.Add(addrTo)
msg.Subject = "Subject goes here"
msg.Body = "Your message body goes here"
' Your SMTP server address goes below
smtp.Host = "smtp.server.com"
smtp.Port = 25
smtp.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
' Add user credentials for foreign mailservers (some providers require
this)
smtp.Credentials = New System.Net.NetworkCredential("username",
"password")
smtp.Send(msg)
Catch ex As Exception
End Try
'----------------------------------------------------------
With this you can specifiy your SMTP server and if necessary user
credentials for authentication. Works for me.
Jeroen
"Anuradha" <anuradhat@lankaequities.com> schreef in bericht
news:O75IQP$%23FHA.1032@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view] > Dear All
>
> I tried below method to send mails but when the mail sends it gives an
> error
> saying
>
> Dim mail As MailMessage = New MailMessage()
> mail.To = "anuradhat@lankequities.com"
> mail.From = "anu@yourcompany.com"
> mail.Subject = "this is a test email."
> mail.Body = "this is my test email body"
> SmtpMail.SmtpServer = "192.168.7.13" 'your real server goes here
> SmtpMail.Send(mail)
>
> end sub
>
>
> Error MSG
>
> ====================================
>
> An unhandled exception of type 'System.Web.HttpException' occurred in
> system.web.dll
>
> Additional information: Could not access 'CDO.Message' object.
>
> =====================================
> How can I get up from this error?
>
>
> Thx
> Anuradha
>
>