473,394 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Email attachment gets corrupted when sending using SMTP server

Hi,

I have a PDF file that I am trying to send as an attachment through a C#
program. Even though the PDF file can be opened by itself, sometimes the
same
file cannot be opened as an attachment. If I try and open the original PDF
file I have no problems.

I have used System.Web.Mail.MailMessage to create an
email and an SMTPMail object to send the mail.
I tried to change the encoding to Base64 but even that has not helped. There
are still ocassions when I am unable to open the attachment.

Has anybody experienced this problem or do you have any suggestions .

Thanks!!
Sep 15 '05 #1
2 8655
New User <Ne*****@discussions.microsoft.com> wrote:
I have a PDF file that I am trying to send as an attachment through a C#
program. Even though the PDF file can be opened by itself, sometimes the
same
file cannot be opened as an attachment. If I try and open the original PDF
file I have no problems.

I have used System.Web.Mail.MailMessage to create an
email and an SMTPMail object to send the mail.
I tried to change the encoding to Base64 but even that has not helped. There
are still ocassions when I am unable to open the attachment.

Has anybody experienced this problem or do you have any suggestions .


Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Sep 15 '05 #2
New User wrote:
Hi,

I have a PDF file that I am trying to send as an attachment through a C#
program. Even though the PDF file can be opened by itself, sometimes the
same
file cannot be opened as an attachment. If I try and open the original PDF
file I have no problems.

I have used System.Web.Mail.MailMessage to create an
email and an SMTPMail object to send the mail.
I tried to change the encoding to Base64 but even that has not helped. There
are still ocassions when I am unable to open the attachment.

Has anybody experienced this problem or do you have any suggestions .

Thanks!!

In my experience, sometimes the "System.Web.Mail" will use a incorrect
attachment encoding even you had set it to "Base64". It seems the
problem is related to some version of "CDO" object installed in the
system by other application(e.g. MS office).
I solve the problem to force the encoding by changing the mail header.
MailMessage message = new MailMessage();
....
MailAttachment attach;
attach = new MailAttachment(file,MailEncoding.Base64);
message.Attachments.Add(attach);
....
//-> add this line
message.Headers.Add("Content-Transfer-Encoding","base64");
....

--
Jacky Kwok
jacky@alumni_DOT_cuhk_DOT_edu_DOT_hk
jacky@compose_DOT_com_DOT_hk
Sep 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jared | last post by:
Hello people, I've had major difficulties finding the right Java technology that can be used to make an e-mail applet program. I'm trying to build an applet that would be similar, but much...
19
by: Bill | last post by:
I have searched through the posts for a question like mine but have only found much more complicated responses. On single record view of a form I have an email address field. I merely want to...
6
by: \jason via DotNetMonster.com\ | last post by:
currently i am doing a personal website and keep on changing the aspect... finally the finall decision is to have a login page (requirement in asp.net, vb.net) and the login with security part of...
2
by: New User | last post by:
Hi, I have a PDF file that I am trying to send as an attachment through a C# program. Even though the PDF file can be opened by itself, sometimes the same file cannot be opened as an...
4
by: JJ | last post by:
Whats the most compatilbe way of sending an email ?- I need to consider that the OS may be win 98/win NT/Win 2000/winXP. I was constructing a mailto command, but the contents of the text file I...
3
by: Vickie | last post by:
have a client trying to send scanned images thru email. He is using RoadRunner with a 10 mb limit for an email. On Friday, I was sent a 5 mb attachment that did come thru, but it took 30 seconds...
4
by: rschaeferhig | last post by:
I have an ASP page that uses CDOSYS to send a simple HTML format email with a PDF attachment. When I open the PDF attached to the email it shows up as a blank page. I log into the web server...
11
by: Ed Bitzer | last post by:
I have been able using the namespace System.Web.Mail and its method Smtp.mail.send to mail simple text messages to a small group within our 55 and older community. I need help expanding the...
2
by: Eric E | last post by:
Hello All - I am using python to send an email with a large zip file as an attachment. I successfully sent a 52M attachment. If I try to send a 63M attachment or larger, the message never gets...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.