-3

Possible Duplicate:
Sending email in .NET through Gmail

I want to send an email using VB.NET2008 and gmail account. Can any one help me in it any code?

Community
  • 1
  • 1
illumi
  • 458
  • 1
  • 14
  • 32

1 Answers1

1
Dim Msg As New MailMessage

Dim myCredentials As New System.Net.NetworkCredential
myCredentials.UserName = " andreas@absender.de"
myCredentials.Password = "Password"

Msg.IsBodyHtml = False

Dim mySmtpsvr As New SmtpClient()
mySmtpsvr.Host = "smtp.web.de" 
mySmtpsvr.Port = 25

mySmtpsvr.UseDefaultCredentials = False
mySmtpsvr.Credentials = myCredentials

Try
  Msg.From = New MailAddress("andreas@absender.de")
  Msg.To.Add("entchen@empfänger.de")
  Msg.Subject = "Betreff"
  Msg.Body = "Inhalt"
  mySmtpsvr.Send(Msg)
  MsgBox("E-Mail gesendet.", MsgBoxStyle.Information, Title:="Information")
Catch ex As Exception
  MsgBox (Err.Number & ex.Message & ex.StackTrace.ToString) 'Falls ein Fehler auftritt wird eine MsgBox angezeigt
End Try 

Hope it helps..

eMi
  • 5,540
  • 10
  • 60
  • 109