failure sending mail

Posted by Nithu under VB.NET on 7/23/2012 | Points: 10 | Views : 4739 | Status : [Member] | Replies : 1
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.gmail.com", 587)

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@gmail.com"

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




Responses

Posted by: Hemanthlaxmi on: 7/23/2012 [Member] Starter | Points: 25

Up
0
Down
Here are some examples of doing a basic html email messages.

http://help.yahoo.com/l/us/yahoo/mail/original/mailplus/pop/pop-14.html

http://stackoverflow.com/questions/684454/how-to-send-mail-from-yahoo-mail-id-in-vb-net-or-c-net-code

If this helps you .
Please "Mark as Answer"

Nithu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response