Hi,
I'm trying to send a mail by SMTP client. It works for me, but the problem that I must specify a password of the sender.
How can I send it without specifying password? I think it should be possible.
As I said - this code is works, but I try to avoid of specifying password ("NetworkCredential" line) .
Many thanks!
I'm trying to send a mail by SMTP client. It works for me, but the problem that I must specify a password of the sender.
How can I send it without specifying password? I think it should be possible.
Code:
Dim msg As New System.Net.Mail.MailMessage()
msg.To.Add("me@mycompany.com")
msg.From = New MailAddress("someone@mycompany.com", "Someone", System.Text.Encoding.UTF8)
msg.Subject = "subject"
msg.SubjectEncoding = System.Text.Encoding.UTF8
msg.BodyEncoding = System.Text.Encoding.UTF8
msg.Priority = MailPriority.High
msg.IsBodyHtml = True
Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString(body, Nothing, "text/plain")
Dim client As New SmtpClient()
[b]client.Credentials = New System.Net.NetworkCredential("me@company.com", "mypassword")[/b]
client.Port = CInt(txtPort.Text)
client.Host = txtSMTPserver.Text
client.EnableSsl = False
client.Send(msg)
As I said - this code is works, but I try to avoid of specifying password ("NetworkCredential" line) .
Many thanks!