I am trying to write code to send a mail message with an attached file.
my code works fine if I don't try to attach a file but crashes when I do. I have not been able to figure this out. My code looks like this.
[
Dim mail As New MailMessage()
'set the addresses
mail.From = New MailAddress("xxx@cox.net")
mail.To.Add("xxx@cox.net")
'set the content
mail.Subject = "Article to be submitted."
mail.Body = Message
mail.Attachments("C:\Project\Articles1\Article.txt")
'send the message
Dim smtp As New SmtpClient("smtp.east.cox.net")
smtp.Port = 25
smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential("xxx", "xxx")
smtp.Send(mail)
]
What am I doing wrong?