Hello,
i have a scenario where i need to send some files present in a particular folder to separate email ids. i call by mail sending subrouting and pass the file location of 1 file at a time. i call this in a loop untill all the files are processed. each file is to be send to different or same users.
i am using the below code
i am able to successfully send files if i provide valid email id in the field email.To .However if i add an invalid email id which doesnt exist say abc@xyz.com
then i get an error message "The operation has timed out"
which is perfectly fine.
however when processing files for which valid email id exists..then i get the error
Failure sending mail
when i restart my application and put valid email ids in the email.to
then everything works properly.
This issue may be probably due to the timeout=60 field. while i am able to send 1st file having valid email id, then 2 file with invalid id giving timed out error, now 3rd file with valid email id in :TO is giving failure sending mail.
Can any one suggest a proper way of tackling this issue.
how can i wait for the timeout to appear and then only get out of mailing sub.
i have a scenario where i need to send some files present in a particular folder to separate email ids. i call by mail sending subrouting and pass the file location of 1 file at a time. i call this in a loop untill all the files are processed. each file is to be send to different or same users.
i am using the below code
VB.NET:
Using email As New System.Net.Mail.MailMessage()
Dim smtp_dtl As New System.Net.Mail.SmtpClient
Dim attach_file As New System.Net.Mail.Attachment(filelocation)
Dim email_from As New System.Net.Mail.MailAddress(from_names)
email.Attachments.Add(attach_file)
email.To.Add(to_names)
email.From = email_from
email.Subject = subject
body = "Hi," & _
vbCrLf & _
"Please find attached " & reparray(rownum, 1).ToString & _
" refreshed on " & repdate & vbCrLf & _
vbCrLf & reparray(rownum, 6).ToString
email.Body = body
smtp_dtl.Host = My.Settings.smtpmain.ToString
smtp_dtl.Port = 25
'smtp_dtl.EnableSsl = True
smtp_dtl.Timeout = 60
smtp_dtl.UseDefaultCredentials = True
smtp_dtl.Send(email)
End Using
i am able to successfully send files if i provide valid email id in the field email.To .However if i add an invalid email id which doesnt exist say abc@xyz.com
then i get an error message "The operation has timed out"
which is perfectly fine.
however when processing files for which valid email id exists..then i get the error
Failure sending mail
when i restart my application and put valid email ids in the email.to
then everything works properly.
This issue may be probably due to the timeout=60 field. while i am able to send 1st file having valid email id, then 2 file with invalid id giving timed out error, now 3rd file with valid email id in :TO is giving failure sending mail.
Can any one suggest a proper way of tackling this issue.
how can i wait for the timeout to appear and then only get out of mailing sub.