smtp DeliveryMethod

  • Thread starter Thread starter Sonu
  • Start date Start date
S

Sonu

Any help with -

'=========== THIS PART IS NOT WORKING ========
section in the code.

I'm not able to send using emails using "C:\temp\" folder!

Any idea!
Thanks
-------------------------------------------------------------------------

Sub SendAsync()
Try
Dim strmsgBody As String = "hello world:
Dim item As String

'Listbox1 items
'(e-mail address removed)
'(e-mail address removed)
'(e-mail address removed) and so on...

For Each item In ListBox1.Items
Dim mail As New Net.Mail.MailMessage()
Dim smtp2 As New Net.Mail.SmtpClient("hostname", "25")
Dim cred As New Net.NetworkCredential("username",
"password")

smtp2.Credentials = cred
mail.IsBodyHtml = False
Dim userState As Object = mail

AddHandler smtp2.SendCompleted, AddressOf
SmtpClient_OnCompleted

'=========== THIS PART IS NOT WORKING ========
smtp2.DeliveryMethod =
Net.Mail.SmtpDeliveryMethod.SpecifiedPickupDirectory
smtp2.PickupDirectoryLocation = "C:\temp\"
'=========== THIS PART IS NOT WORKING ========

smtp2.SendAsync("(e-mail address removed)", item.ToString, "Subject",
strmsgBody, userState)
smtp2 = Nothing
Next

Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

Public Sub SmtpClient_OnCompleted(ByVal sender As Object, ByVal e As
System.ComponentModel.AsyncCompletedEventArgs)
Dim mail As Net.Mail.MailMessage = CType(e.UserState,
Net.Mail.MailMessage)
Dim subject As String = mail.Subject

If e.Cancelled Then
MessageBox.Show("Send canceled for mail with subject:", subject,
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If

If Not (e.Error Is Nothing) Then
MessageBox.Show("error")
Else
MessageBox.Show("msg sent")
End If
End Sub
 
I would have to guess that "C:\Temp" is not the pickup directory for your
SMTP server.

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP
 
Back
Top