Dear all,
I tried using the following code to send email.
First, I was getting "unable to relay" message.
Then I granted access to localhost (127.0.0.1).
Now, I no longer get the error but I don't receive any emails.
What am I doing wrong?
Please see my entire code.
THanks in advance.
I invoked it by simply putting
sendRequest() in sendButton() event handler.
I tried using the following code to send email.
First, I was getting "unable to relay" message.
Then I granted access to localhost (127.0.0.1).
Now, I no longer get the error but I don't receive any emails.
What am I doing wrong?
Please see my entire code.
THanks in advance.
Code:
Sub sendRequest()
'create the mail message
Dim mail As New MailMessage()
'set the addresses
'to specify a friendly 'from' name, we use a different ctor
mail.From = New MailAddress("helpdesk@work.com", "Help Desk")
'since the To,Cc, and Bcc accept addresses, we can use the same technique as the From address
'since the To, Cc, and Bcc properties are collections, to add multiple addreses, we simply call .Add(...) multple times
mail.To.Add("john.doe@yahoo.com")
'set the content
mail.Subject = "This is an email"
mail.Body = "this is the body content of the email."
'send the message
Dim smtp As New SmtpClient("127.0.0.1")
smtp.Send(mail)
End Sub 'sendRequest
I invoked it by simply putting
sendRequest() in sendButton() event handler.