Groups | Blog | Home
all groups > vb.net controls > december 2005 >

vb.net controls : Sending Mails


Anuradha
12/8/2005 6:34:56 PM
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

Ray Cassick (Home)
12/13/2005 1:39:11 AM
What line throws the exception?

[quoted text, click to view]

Rotzooi
12/28/2005 3:29:58 PM
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]

AddThis Social Bookmark Button