Monday, May 24, 2010

How to send an e-mail using Visual Basic 2005 Express?

In webpages, I can use PHP to send an e-mail using a fom, correct? Now, how to do a similar thing using a Windows Application made by Visual Basic 2005 Express Edition. Please refer to the sumbit button as "Button1" and to the

How to send an e-mail using Visual Basic 2005 Express?
Public Shared Sub SendHtmlMessage(ByVal ToEmail As String, ByVal ToName As String, _


ByVal FromEmail As String, ByVal FromName As String, _


ByVal Subject As String, ByVal MessageBody As String, _


Optional ByVal BccEmail As String = "", Optional ByVal BccName As String = "")





Dim ToAddress As New Mail.MailAddress(ToEmail, ToName)


Dim FromAddress As New Mail.MailAddress(FromEmail, FromName)


Dim MessageToSend As New Mail.MailMessage(FromAddress, ToAddress)





With MessageToSend


.IsBodyHtml = True


.Subject = Subject


.Body = MessageBody


.ReplyTo = New Mail.MailAddress("donotreply@bla.com", "Name")


If BccEmail.Trim %26lt;%26gt; "" And BccName.Trim %26lt;%26gt; "" Then


.Bcc.Add(New Mail.MailAddress(BccEmail, BccName))


ElseIf BccEmail.Trim %26lt;%26gt; "" Then


.Bcc.Add(New Mail.MailAddress(BccEmail))


End If


End With





Dim MailObj As New Mail.SmtpClient


MailObj.Host = "ExchangeServerIP"


MailObj.Send(MessageToSend)
Reply:Got to microsoft and get tutorials and find out how.


No comments:

Post a Comment