0

私は自分のコードに似たStackOverflowの投稿をいくつか見てきましたが、コードを微調整しましたが、まだ機能していません。私のコードは、以下のあなたの熟読のためにpatedされています:

Dim ss As SmtpClient = New SmtpClient("smtp.gmail.com", 587)
    'Dim ss As SmtpClient = New SmtpClient("smtp.gmail.com",465 )
    'Dim ss As SmtpClient = New SmtpClient("smtp.gmail.com", 25)
    ss.Timeout = 10000
    ss.DeliveryMethod = SmtpDeliveryMethod.Network
    ss.UseDefaultCredentials = False
    ss.EnableSsl = True
    ss.UseDefaultCredentials = False
    ss.Credentials = New NetworkCredential("name@gmail.com", "name@123")


    Dim subject As String = "Approval request for Quotation with Order Number: " + Me.OrderNo

    Dim body As String = "Dear Sir/Madam," + vbCrLf + " This is to bring to your notice the quotation for the Client " + Me.cmbCustomer.SelectedItem.Text + " and Order Number " + Me.OrderNo & _
        " which is awaiting your approval." + vbCrLf + "Click here to view and approve the Quotation: http:192.168.20.7/appname/Sales/ManageInvoices.aspx" + vbCrLf & _
        " Kindly revert after approval. Thank you." + vbCrLf + "Regards."

    Dim To1, To2, To3 As String

    Dim mm As MailMessage = New MailMessage()
    mm.From = New MailAddress("name@gmail.com")

    To1 = "usernameTo1@domain.com"
    To2 = "usernameTo2@domain.com"
    To3 = "usernameTo3@gmail.com"
    'To is a collection of MailAddress types
    mm.To.Add(To1)
    mm.To.Add(To2)
    mm.To.Add(To3)

    mm.Subject = subject
    mm.Body = body

    mm.BodyEncoding = UTF8Encoding.UTF8
    'mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
    Try
        ss.Send(mm)
    Catch ex As SmtpException
        Me.lblerr.Text = "SMTP Err:" & ex.ToString
    End Try

では、メールが宛先に届かないようにするにはどうすればよいでしょうか。エラーメッセージがまったく表示されません。感謝を助けてください。

4

1 に答える 1

0

Gmail の場合、ポートを 587 に設定する必要があります。

<system.net>
    <mailSettings>
      <smtp from="myn@gmail.com ">
        <network host="smtp.gmail.com" defaultCredentials="false"
          port="587" userName ="me@gmail.com" password="pass@123" />
      </smtp>
    </mailSettings>
   </system.net>
于 2012-11-22T17:21:04.200 に答える