>MailAddress from = new MailAddress("Myfrom@address.com"); >MailAddress to = new MailAddress("MyTo1@address.com"); >MailMessage message = new MailMessage(from, to); >>
Public Sub Send(ByVal from As String, _ ByVal recipient As String, _ ByVal cc As String, _ ByVal bcc As String, _ ByVal subject As String, _ ByVal body As String, _ ByVal priority As MailPriority, _ Optional ByVal isBodyHTML As Boolean = False) Dim msg As MailMessage Try msg = New MailMessage msg.From = New MailAddress(from) msg.To.Add(recipient) If cc.Length > 0 Then msg.CC.Add(cc) End If If bcc.Length > 0 Then msg.Bcc.Add(bcc) End If msg.Subject = subject msg.Body = body msg.Priority = priority msg.IsBodyHtml = isBodyHTML Me.Send(msg) Catch ex As Exception Throw New ApplicationException("Error sending email.") Finally If Not (msg Is Nothing) Then msg.Dispose() End If End Try End Sub Public Sub Send(ByVal msg As MailMessage) Dim smtp As SmtpClient Try smtp = New SmtpClient(Me.EmailServer) smtp.Send(msg) Catch ex As Exception Throw New ApplicationException("Error sending email.") End Try End Sub