Kevin Spencer
3/10/2008 11:56:00 AM
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
"Sonu" <replymeonly@hotmail.com> wrote in message
news:323BDDB1-32B0-4FE5-864B-260486CE3282@microsoft.com...
> 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
> 'email@hotmail.com
> 'email2@hotmail.com
> 'email3@hotmail.com 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("from@email.com", 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
>