Sending Email through VB.Net...

  • Thread starter Thread starter asad.naeem
  • Start date Start date
A

asad.naeem

Try
Dim MMsg As MailMessage = New MailMessage
'MMsg.SubjectEncoding = Encoding.Default
MMsg.BodyEncoding = Encoding.Default
MMsg.From = "(e-mail address removed)"
MMsg.To = "(e-mail address removed)"
MMsg.Subject = "Email with Subject Demo"
MMsg.Body = "This is the main body of the email"
MMsg.Priority = MailPriority.High
MMsg.BodyFormat = MailFormat.Html
System.Web.Mail.SmtpMail.SmtpServer = "127.0.0.1"
'Try
System.Web.Mail.SmtpMail.Send(MMsg)
lblmsg.Text = "Message sent successfully!"
lblmsg.ForeColor = System.Drawing.Color.Green
Catch ex As Exception
lblmsg.Text = ex.Message + " " + ex.StackTrace + " " +
ex.HelpLink
lblmsg.ForeColor = System.Drawing.Color.Red
End Try
// This code successfully run no exception occurs but mails are not
being recived on the TO Address and mails are still in the folder ie,
C:\Inetpub\mailroot\Queue

how to solve this problem...
(e-mail address removed)
 
SmtpServer which you have mentioned is local machine. Have a proper
smtp server relay setup on your machine. It should work fine.

Regards,
Krishna
 
Back
Top