Hi,
i need to send the mail from my project in VB.Net
how to write the generic code for all domain
main problem is not able to send the mail from yahoo and other domains expect gmail
From gmail case it work
From yahoo or hotmail it not work
the sender domain is get from user so need the generic code for send to one domain another one
Error msg : failure sending mail
Public Function Mailing_Document()
Dim message As System.Net.Mail.MailMessage
Dim smtp As New System.Net.Mail.SmtpClient("smtp.mail.yahoo.com", 465)
Dim attach As System.Net.Mail.Attachment
Dim sFrom As String, sTo As String, sSsub As String, sMsg As String
Dim sFile As String
sFrom = "mailagain@yahoo.in"
sTo = "mailme@gmail.com"
sFile = "C:\Documents and Settings\Admin\Desktop\document.pdf"
sSsub = "PO_Invoice-Detail"
sMsg = "Ref the Attachment for detail of invoice"
message = New System.Net.Mail.MailMessage(sFrom, sTo, sSsub, sMsg)
message.Bcc.Add("mailmeonce@yahoo.in")
message.CC.Add("mailonceagain@gmail.com")
If My.Computer.FileSystem.FileExists(sFile) Then
attach = New System.Net.Mail.Attachment(sFile)
message.Attachments.Add(attach)
End If
smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential(sFrom, "chhhe12")
Try
smtp.Send(message)
MessageBox.Show("Well, the mail message appears to have been a success!", " Successful?", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch exc As Net.Mail.SmtpException
MessageBox.Show(exc.StatusCode.ToString, " Something Happened?", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Function