This code showz hot to send a mail with attachment in vb.net
Public Sub MailFormat(ByVal fromAddress As String, ByVal toAddress As String, ByVal body As String, ByVal subject As String, ByVal attachFile As String)
'Format written to send mail with attachment
Dim message As MailMessage = New MailMessage() message.IsBodyHtml = True message.To.Add(toAddress) message.Subject = subject message.From = New MailAddress(fromAddress) message.Body = body.ToString() message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
If Not attachFile Is Nothing Then
Dim attachFiles As Attachment = New Attachment(attachFile) message.Attachments.Add(attachFiles)
End If
Dim smtp As SmtpClient = New SmtpClient(ConfigurationManager.AppSettings(NAPResource.hostName), ConfigurationManager.AppSettings(NAPResource.portNumber))
smtp.Send(message)
End Sub
|
No responses found. Be the first to respond and make money from revenue sharing program.
|