L
Lee Alexander
Hi,
There seems to be a bug with sending mail using SmtpMail.Send. If you send
an email using an SMTP server having an attachment with no body filled in
then the attachment gets corrupted on the recieving end (I attached a pdf
file). Find the code I used below. Note you will have to change the server
email addresses etc...
using System;
using System.Web.Mail;
namespace SendMail
{
class Class1
{
[STAThread]
static int Main(string[] args)
{
MailMessage message = new MailMessage();
message.Body = null;
message.Attachments.Add( new MailAttachment(@"d:\SomePDF.pdf",
MailEncoding.Base64 ));
message.Subject = "test";
message.From = (e-mail address removed);
message.To = "(e-mail address removed)";
SmtpMail.SmtpServer = "Some SMTP server";
SmtpMail.Send( message );
return 0;
}
}
}
P.S don't forget to include a reference to System.Web.dll otherwise it won't
compile.
If you want this example to work then you need to change 'message.Body =
null' to 'message.Body = String.Empty'.
Seems like a bug to me....
Regards
Lee
There seems to be a bug with sending mail using SmtpMail.Send. If you send
an email using an SMTP server having an attachment with no body filled in
then the attachment gets corrupted on the recieving end (I attached a pdf
file). Find the code I used below. Note you will have to change the server
email addresses etc...
using System;
using System.Web.Mail;
namespace SendMail
{
class Class1
{
[STAThread]
static int Main(string[] args)
{
MailMessage message = new MailMessage();
message.Body = null;
message.Attachments.Add( new MailAttachment(@"d:\SomePDF.pdf",
MailEncoding.Base64 ));
message.Subject = "test";
message.From = (e-mail address removed);
message.To = "(e-mail address removed)";
SmtpMail.SmtpServer = "Some SMTP server";
SmtpMail.Send( message );
return 0;
}
}
}
P.S don't forget to include a reference to System.Web.dll otherwise it won't
compile.
If you want this example to work then you need to change 'message.Body =
null' to 'message.Body = String.Empty'.
Seems like a bug to me....
Regards
Lee