System.Web.Mail.MailMessage - AttachFile - corrupted

  • Thread starter Thread starter Slava ilyin
  • Start date Start date
S

Slava ilyin

Can not find how to force MailMessage to send attached file in base64
format. Even if you added
pMsg.Headers.Add("Content-Transfer-Encoding","base64") in your code -
it is not worked if you have HTMLBody in message (quated-printable is
used for attach instead of base64).
That is the reason of very serious trouble!
For example, I have found some "." chars lost in the received file
,etc...

The only one possible fix I've found is to
use CDOEX.dll interop instead:

Interop::CDO::MessageClass* o = new Interop::CDO::MessageClass();
o->To = "..";
o->From = "..";
o->Subject = "subj";


o->BodyPart->ContentTransferEncoding = "base64";
o->BodyPart->Fields->Update();

o->HTMLBody = "Test";


Interop::CDO::IBodyPart* obp = o->AddAttachment
("c:\\Test.xls","","");
obp->ContentTransferEncoding = "base64";
obp->Fields->Update();

o->Send();

OR

Interop::CDONTS::NewMailClass * MailMessage = new
Interop::CDONTS::NewMailClass;

MailMessage->From = "..";
....
MailMessage->BodyFormat = 0;
MailMessage->MailFormat = 0;
MailMessage->AttachFile("...", "...", 1 ) ;
MailMessage->Send();


Any suggestions on this?

Thanks,
Slava
 
System.Web.Mail.MailMessage.Attachments Specifies the collection of
attachments that are transmitted with the message.

The Attachments member is An IList collection of MailAttachment objects.

System.Web.Mail.MailAttachment.Encoding is one of the MailEncoding values.

I think you want System.Web.Mail.Base64

All this is available in the msdn documentation of these classes. Thats
where I found it.

--------------------
This posting is provided "AS IS" with no warranties, and
confers no rights.

Please do not send e-mail directly to this alias. This
alias is for newsgroup purposes only.

Thanks
Nick

--------------------
 
Back
Top