تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
مشكلة في كود ارسال ايميل من جيميل
#4
السيرفر الخاص بالارسال عند حضرتك هو سيرفر Hotmail و ليس سيرفر Gmail
عموما الكود الخاص بالارسال هو :

Imports System.Net.Mail
Public Class mailform
Dim mail As New MailMessage()

Private Sub mailform_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
TextBox2.Text = "xyz@gmail.com"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim SmtpServer As New SmtpClient()
SmtpServer.Credentials = New Net.NetworkCredential
("xyz@gmail.com", "password")
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True

mail = New MailMessage()
Dim addr() As String = TextBox1.Text.Split(",")
Try
mail.From = New MailAddress("xyz@gmail.com",
"Web Developers", System.Text.Encoding.UTF8)

Dim i As Byte
For i = 0 To addr.Length - 1
mail.To.Add(addr(i))
Next
mail.Subject = TextBox3.Text
mail.Body = TextBox4.Text
If ListBox1.Items.Count <> 0 Then
For i = 0 To ListBox1.Items.Count - 1
mail.Attachments.Add(New Attachment
(ListBox1.Items.Item(i)))
Next
End If
mail.DeliveryNotificationOptions =
DeliveryNotificationOptions.OnFailure
mail.ReplyTo = New MailAddress(TextBox1.Text)
SmtpServer.Send(mail)
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
ListBox1.Items.Add(OpenFileDialog1.FileName)
End If
End Sub
End Class
الرد }}}
تم الشكر بواسطة: samira20


الردود في هذا الموضوع
RE: مشكلة في كود ارسال ايميل من جيميل - بواسطة menams2010 - 09-10-16, 04:29 PM


التنقل السريع :


يقوم بقرائة الموضوع: