 |
|
ตัวอย่างชุดที่ 1 Host เป็น MailServer ส่ง email ได้ ไม่มีปัญหาค่ะ
แต่..ตัวอย่างชุดที่ 2 ต้องการส่งเข้า Gmail ไม่ผ่านค่ะ error ว่า Failure Sending mail
เป็นเพราะอะไรคะ รบกวนด้วยค่ะ
ชุดที่ 1
Dim strFrom As String = "[email protected]" 'จาก
Dim strCC As String = "" 'CC
Dim strBCC As String = "" 'BCC
Dim strSubject As String = "Subject" ' ชื่อเรื่อง
Dim strBody As String = "Message" ' ข้อความ
'ส่งเมล
Dim mailMessage As New System.Net.Mail.MailMessage(strFrom, "[email protected]", strSubject, strBody)
Dim mailClient As New System.Net.Mail.SmtpClient("192.168.0.19", 25) 'mail server
mailClient.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
mailClient.Send(mailMessage)
ชุดที่ 2
Dim strFrom As String = "[email protected]" 'จาก
Dim strCC As String = "" 'CC
Dim strBCC As String = "" 'BCC
Dim strSubject As String = "Subject" ' ชื่อเรื่อง
Dim strBody As String = "Message" ' ข้อความ
'ส่งเมล
Dim mailMessage As New System.Net.Mail.MailMessage(strFrom, "[email protected]", strSubject, strBody)
Dim mailClient As New System.Net.Mail.SmtpClient("smtp.gmail.com", 587) 'gmail
mailClient.EnableSsl = True
mailClient.UseDefaultCredentials = False
mailClient.Credentials = New System.Net.NetworkCredential("[email protected]", "password ของ gmail") 'ระบุชื่อผู้ใช้เพื่อส่งเมล์ ข้อจำจัดของ smtp
mailClient.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
mailClient.Send(mailMessage)
Tag : .NET, Ms SQL Server 2012, VB.NET, C#
|
ประวัติการแก้ไข 2015-07-09 16:33:50
|
 |
 |
 |
 |
Date :
2015-07-09 16:30:51 |
By :
alonewin |
View :
3484 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |