Dears Experts,
I tried to send email and attached a file to it from VB.NET code using the SmtpClient, but unfortunatily when I exexuted the code I got the following error. Could you please adivce
Module Module1
Sub Main()
pushMail("SDP-Daily", "SDP-Daily@mycom.com", "me@mycom.com", "SDP-Daily")
End Sub
Public Sub pushMail(ByVal senderName As String, ByVal from As String, ByVal toAddress As String, ByVal subject As String)
Dim objMail As New System.Net.Mail.MailMessag
e
Dim addrss As System.Net.Mail.MailAddres
s = New System.Net.Mail.MailAddres
s(from)
objMail.From = addrss
objMail.To.Add(toAddress)
objMail.Subject = subject
'objMail.IsBodyHtml = True
objMail.Body = "test"
Dim objAttch As Net.Mail.Attachment = New Net.Mail.Attachment("C:\SD
P-07042008
.xls")
objMail.Attachments.Add(ob
jAttch)
Dim client As System.Net.Mail.SmtpClient
= New System.Net.Mail.SmtpClient
("RUH-003-
MX-001") 'the Client used in our lan
Try
client.Send(objMail)
objMail.To.Clear()
Catch ex As Exception
End Try
End Sub
End Module
Start Free Trial