I've updated my old style of sending emails from
System.Web.Mail
to a more updated style:
System.Net.Mail
Sub SendEmail()
Using objMailMessage As New MailMessage()
objMailMessage.From = New MailAddress(txtFrom.Text)
objMailMessage.To.Add(txtTo.Text)
objMailMessage.Subject = txtSubject.Text
objMailMessage.Body = txtContent.Text & " | email sent from " & strUser & "'s pc"
objMailMessage.IsB开发者_Go百科odyHtml = True
objMailMessage.Priority = MailPriority.Normal
objSmtpClient = New SmtpClient("server_name_goes_here")
objSmtpClient.Send(objMailMessage)
End Using
End Sub
The problem is that the new style, does not let me type in a mail group name.
For example, in the old style, I was able to type in
objMailMessage.From = "HR Department"
HR Department was a group of emails set on the exchange server which had everyone in the HR listed and would send the email to all of them.
In the new coding style, It does not let me do that. Each time I try, it gives me a message saying that I have not entered in a proper email address.
i.e, this does not work:
objMailMessage.From = New MailAddress("HR Department")
I have to do this
objMailMessage.From = New MailAddress("hr_user_1@mail.com, hr_user_2@mail.com, hr_user_3@mail.com")
Try replacing this:
objMailMessage.From = New MailAddress("HR Department")
To this:
objMailMessage.From = New MailAddress("HR Department@yourdomain.com", "HR Department")
精彩评论