Hello
In the following code, the Webmaster receives the sender's email, but his assistant, who should be copied in (CC) does not. Instead, what is happening is that the person who should be copied in, well his email address appears under CC in the Webmaster's inbox, but he does not receive the message in his own inbox.
There are no server errors.
The code looks like this, but there must be something wrong with the CC (and BCC) part of the code.
Thank you for any advice.
In the following code, the Webmaster receives the sender's email, but his assistant, who should be copied in (CC) does not. Instead, what is happening is that the person who should be copied in, well his email address appears under CC in the Webmaster's inbox, but he does not receive the message in his own inbox.
There are no server errors.
The code looks like this, but there must be something wrong with the CC (and BCC) part of the code.
VB.NET:
Protected Sub SendEmail_Click(sender As Object, e As System.EventArgs)
Dim myMessage As New MailMessage
Dim Smtpserver As New SmtpClient
Dim user_name As String = Request.Form("user_name")
Dim user_email As String = Request.Form("user_email")
Dim user_subject As String = Request.Form("user_subject")
Dim user_message As String = Request.Form("user_message")
Dim CC As MailAddress = New MailAddress("myemail@whatever.com")
Dim BCC As MailAddress = New MailAddress
myMessage.From = New MailAddress(user_email) 'User's email
myMessage.To.Add(New MailAddress("info@Webmaster.net")) 'Webmaster
myMessage.CC.Add(New MailAddress("myemail@whatever.com")) 'Webmaster's assistant
myMessage.Bcc.Add(New MailAddress("user_email")) 'blind copy to user's email address
myMessage.Subject = user_subject
myMessage.Body = user_message
myMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
myMessage.IsBodyHtml = True
myMessage.Priority = MailPriority.Normal
Smtpserver.DeliveryMethod = SmtpDeliveryMethod.Network
Smtpserver.Host = ("mail.server")
Smtpserver.Port = 25
Smtpserver.EnableSsl = False
Dim basicAuthenticationInfo As New System.Net.NetworkCredential("info@webmaster.net", "password")
Smtpserver.Credentials = basicAuthenticationInfo
Smtpserver.Send(myMessage)
myMessage.Dispose()
myMessage = Nothing
Smtpserver = Nothing
End Sub
Thank you for any advice.