I'm having a hard time getting this e-mail code to include a CC address. I've had to strip this down to keep confidential information out of it. If something looks wrong, this code does work in the form I have it in. But when I try to include the CC address I get an error saying the Property 'CC' is ReadOnly. How does one include a cc in the e-mail using SMTP?
Code:
Public Module EmailIt
Public Sub email_it(ByVal dwgno As String, ByVal UserName As String, ByVal pdffile As Integer)
Dim email_to As String
Dim email_from As String
Dim email_subject As String
Dim email_body As String
Dim email_cc As String = "emailcc@mydomain.com"
email_to = UserName & "@mydomain.com"
email_from = "me@mydomian.com"
email_subject = "Here is the Subject Line"
email_body = "This is the body of the e-mail message
Dim smtpServer As New System.Net.Mail.SmtpClient
smtpServer.Host = "localhost"
smtpServer.Port = 25
smtpServer.Timeout = 60
Dim message As New Net.Mail.MailMessage(email_from, email_to)
message.Subject = email_subject
message.Body = email_body
message.CC = email_cc
message.BodyEncoding = System.Text.Encoding.UTF8
message.Headers.Add("Reply-To", email_from)
message.Headers.Add("X-Organization", "AnyOld Corporation")
Dim user_state As String = " - Mail Message"
smtpServer.SendAsync(message, user_state)
End Sub
End Module