By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,783 Members | 1,347 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,783 IT Pros & Developers. It's quick & easy.

Mail attachment problem

P: n/a
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);
May 12 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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/lib...ttachment.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 Nietzsche
May 12 '06 #2

P: n/a
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
May 12 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.