Mail attachment problem

R

Ray

Hi

Can anyone help with something that has beaten me.

I am sending an email with an attachment, as per below. If I comment out the
MailAttachment line then the mail gets sent, but with it in I get an error.
Can anybody point me in the right direction?

Thanks



Ray

MailMessage MyMail = new MailMessage();



string txt="this is my attachment";

MailAttachment MyAttachment = new MailAttachment(txt);

SmtpMail.SmtpServer = server;

SmtpMail.Send(MyMail);
 
M

Michael Nemtsev

Hello Ray,

If you are using .NET FW 2.0 MailAttachment is obsolete class. Use Mail.Attachment
in lue of.
Sample is there http://msdn2.microsoft.com/en-us/library/system.net.mail.attachment.aspx

R> Hi
R> Can anyone help with something that has beaten me.
R> I am sending an email with an attachment, as per below. If I comment
R> out the MailAttachment line then the mail gets sent, but with it in I
R> get an error. Can anybody point me in the right direction?
R>
R> Thanks
R>
R> Ray
R> MailMessage MyMail = new MailMessage();
R> string txt="this is my attachment";
R> MailAttachment MyAttachment = new MailAttachment(txt);
R> SmtpMail.SmtpServer = server;
R> SmtpMail.Send(MyMail);
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
M

Michael Nemtsev

Try this sample http://www.codeproject.com/csharp/smtpemailer.asp

R> Can anyone help with something that has beaten me.
R>
R> I am sending an email with an attachment, as per below. If I comment
R> out the MailAttachment line then the mail gets sent, but with it in I
R> get an error. Can anybody point me in the right direction?
R>
R> Thanks
R>
R> Ray
R>
R> MailMessage MyMail = new MailMessage();
R>
R> string txt="this is my attachment";
R>
R> MailAttachment MyAttachment = new MailAttachment(txt);
R>
R> SmtpMail.SmtpServer = server;
R>
R> SmtpMail.Send(MyMail);
R>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top