If your mail server requires a user ID and password, you will need to set "MailClient.UseDefaultCredentials = .f." and on the very next line add:
Code:
MailClient.Credentials = new System::Net::NetworkCredential(EmailUserid, EmailPassword)
MailClient.Send() does not return an error result. That's why you were getting the error message. I too was stumped a couple months ago on how to be sure the email was sent. You need to use the "on error" statement just before instantiating the SmtpClient in order to check for .Net exceptions:
Code:
on error goto Error_Handler
dim MailClient as System::Net::Mail::SmtpClient = new System::Net::Mail::SmtpClient("email.email.com",25)
MailClient.EnableSsl = .F.
MailClient.UseDefaultCredentials = .T.
MailClient.Send(msg)
vjscmd = "alert('An email to the approver of this tool request has been sent telling them that it has been completed.');"
msg.Dispose()
. . .
return
Error_Handler:
ErrorCode = error_code_get()
ErrorLine = error_line_number_get()
ErrorMessage = error_text_get()
msg.Dispose()
. . .
(end of function)
You can test the error handler by using an invalid smtp server name or port number. All of the "error_" functions are optional of course.
Hope this helps.
Bookmarks