i am trying to add the functionality into my code to send an email.
this is my code snippet.
Expand|Select|Wrap|Line Numbers
- using System;
- using System.IO;
- using System.Net.Mail;
- namespace logchecktest1
- {
- class Program
- {
- private void SendMail()
- {
- MailMessage MyMail = new MailMessage();
- SmtpClient server = new SmtpClient("localhost"); // from server
- MyMail.From = new MailAddress("support@test.com");
- MyMail.To = new MailAddress("kwareham@test.com");
- MyMail.Subject = "arerror log";
- MyMail.Body = "errors found in arerror log - go check -(@'C:\\Documents and Settings\\kwareham01\\Desktop\\test.txt')";
- server.Send(MyMail);
- }
cannot implicitly convert type 'System.Net.Mail.MailAddress' to 'System.Net.MailAddressCollection' &
Property or indexer 'System.Net.Mail.MailMessage.To' cannot be assigned to -- it is read only
if i take out the 'To' and have just MyMail. = new ...
i get just the 1 error - 'identifier expected'
any help would be appreciated
thanks