473,569 Members | 2,879 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8682
New User <Ne*****@discus sions.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.co m>
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.Mai l" 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,MailEncodi ng.Base64);
message.Attachm ents.Add(attach );
....
//-> add this line
message.Headers .Add("Content-Transfer-Encoding","base 64");
....

--
Jacky Kwok
jacky@alumni_DO T_cuhk_DOT_edu_ DOT_hk
jacky@compose_D OT_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
6750
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 simpler, than Hotmail or Webmail. I've been told by our system administrator that I can't access our SMTP and POP3 servers directly. If I could use...
19
2769
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 create a button that will email the same message (and idealy a word attachment) to whatever address is in view on the form (chances are that I just...
6
2768
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 capturing user computer user name i have done... my problem is .... i need the unregistered user to log in to my site and from there there will...
2
411
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 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...
4
2256
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 am using as the subject is too long and gets cut off. I therefore need a method that doesn't use the limitations of mailto (in terms of the length of...
3
1144
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 for the message to leave the clients mail box. I did think this was a bit of a long time, but suggested that he send each item in it's own email...
4
12223
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 console and open the same PDF in the source directory and it opens fine. I run a binary comparison of the source and attached files and there's a...
11
3491
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 programs capabilities. Searching this forum I did not find any related information so if I have chosen poorly, I would appreciate a suggestion of a more...
2
6858
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 through. I do not get any errors in my python code. I pasted my python code below. from email.MIMEBase import MIMEBase from...
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7619
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7681
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.