Hi, all!
I'm trying to use the System.Web.Mail. "package" combinded
with System.Web.Mail.SmtpMail in order to send MS Excel
spreadsheets attached to mail messages. However, sending
one single spreadsheet attachment per message, seems to be
causing som kind of corruption of the attachment, while
several spreadsheets per works just fine. Consider the
following three snippets of C# code:
// Sample 1 ->
System.Web.Mail.MailMessage msg = new
System.Web.Mail.MailMessage();
msg.Attachments.Add(new System.Web.Mail.MailAttachment
("some_spreadsheet.xls"));
msg.Attachments.Add(new System.Web.Mail.MailAttachment
("some_other_spreadsheet.xls"));
msg.From = "me@mydomain.com;
msg.To = "so*****@somewhere.com";
msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail.SmtpMail.SmtpServer = "some_smtp_server";
System.Web.Mail.SmtpMail.Send(msg);
// Sample 2 ->
System.Web.Mail.MailMessage msg = new
System.Web.Mail.MailMessage();
msg.Attachments.Add(new System.Web.Mail.MailAttachment
("some_spreadsheet.xls"));
msg.From = "me@mydomain.com;
msg.To = "so*****@somewhere.com";
msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail.SmtpMail.SmtpServer = "some_smtp_server";
System.Web.Mail.SmtpMail.Send(msg);
// Sample 3 ->
System.Web.Mail.MailMessage msg = new
System.Web.Mail.MailMessage();
msg.Attachments.Add(new System.Web.Mail.MailAttachment
("some_other_spreadsheet.xls"));
msg.From = "me@mydomain.com;
msg.To = "so*****@somewhere.com";
msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail.SmtpMail.SmtpServer = "some_smtp_server";
System.Web.Mail.SmtpMail.Send(msg);
Using the code in Sample 1, both attatchments can be
opened by Excel without any problem, as they arrive at the
receiving end.
Using the code in Sample 2 or Sample 3, however, NEITHER
of the attachments, which happens to be the EXACT same two
Excel spreadsheets as in Sample1, can be opened by the
receipient using Excel. Any ettemt two open them results
in either a "The document is corrupt and cannot be opened.
To try an repair..." error message or a " cannot
be accessed. The file may be read-only, or..." error
message. If any of you have an idea what's causing this
problem, and maybe even a suggestion for a workaround,
your reply would be highly appreciated.
Regards, Trond 4 8628
Try to use encoding parameter in MailAttachment constructor.
"Trond A. S. Andersen" <ts*@scandpower.no> wrote in message
news:08****************************@phx.gbl... Hi, all!
I'm trying to use the System.Web.Mail. "package" combinded with System.Web.Mail.SmtpMail in order to send MS Excel spreadsheets attached to mail messages. However, sending one single spreadsheet attachment per message, seems to be causing som kind of corruption of the attachment, while several spreadsheets per works just fine. Consider the following three snippets of C# code:
// Sample 1 ->
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage(); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_spreadsheet.xls")); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_other_spreadsheet.xls"));
msg.From = "me@mydomain.com; msg.To = "so*****@somewhere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail.SmtpMail.SmtpServer = "some_smtp_server"; System.Web.Mail.SmtpMail.Send(msg);
// Sample 2 ->
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage(); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_spreadsheet.xls"));
msg.From = "me@mydomain.com; msg.To = "so*****@somewhere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail.SmtpMail.SmtpServer = "some_smtp_server"; System.Web.Mail.SmtpMail.Send(msg);
// Sample 3 ->
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage(); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_other_spreadsheet.xls"));
msg.From = "me@mydomain.com; msg.To = "so*****@somewhere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail.SmtpMail.SmtpServer = "some_smtp_server"; System.Web.Mail.SmtpMail.Send(msg);
Using the code in Sample 1, both attatchments can be opened by Excel without any problem, as they arrive at the receiving end.
Using the code in Sample 2 or Sample 3, however, NEITHER of the attachments, which happens to be the EXACT same two Excel spreadsheets as in Sample1, can be opened by the receipient using Excel. Any ettemt two open them results in either a "The document is corrupt and cannot be opened. To try an repair..." error message or a " cannot be accessed. The file may be read-only, or..." error message. If any of you have an idea what's causing this problem, and maybe even a suggestion for a workaround, your reply would be highly appreciated.
Regards, Trond
Try to use encoding parameter in MailAttachment constructor.
"Trond A. S. Andersen" <ts*@scandpower.no> wrote in message
news:08****************************@phx.gbl... Hi, all!
I'm trying to use the System.Web.Mail. "package" combinded with System.Web.Mail.SmtpMail in order to send MS Excel spreadsheets attached to mail messages. However, sending one single spreadsheet attachment per message, seems to be causing som kind of corruption of the attachment, while several spreadsheets per works just fine. Consider the following three snippets of C# code:
// Sample 1 ->
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage(); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_spreadsheet.xls")); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_other_spreadsheet.xls"));
msg.From = "me@mydomain.com; msg.To = "so*****@somewhere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail.SmtpMail.SmtpServer = "some_smtp_server"; System.Web.Mail.SmtpMail.Send(msg);
// Sample 2 ->
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage(); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_spreadsheet.xls"));
msg.From = "me@mydomain.com; msg.To = "so*****@somewhere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail.SmtpMail.SmtpServer = "some_smtp_server"; System.Web.Mail.SmtpMail.Send(msg);
// Sample 3 ->
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage(); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_other_spreadsheet.xls"));
msg.From = "me@mydomain.com; msg.To = "so*****@somewhere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail.SmtpMail.SmtpServer = "some_smtp_server"; System.Web.Mail.SmtpMail.Send(msg);
Using the code in Sample 1, both attatchments can be opened by Excel without any problem, as they arrive at the receiving end.
Using the code in Sample 2 or Sample 3, however, NEITHER of the attachments, which happens to be the EXACT same two Excel spreadsheets as in Sample1, can be opened by the receipient using Excel. Any ettemt two open them results in either a "The document is corrupt and cannot be opened. To try an repair..." error message or a " cannot be accessed. The file may be read-only, or..." error message. If any of you have an idea what's causing this problem, and maybe even a suggestion for a workaround, your reply would be highly appreciated.
Regards, Trond
Tried that. Excel spreadsheet attachments somehow
corrupted by the System.Web.Mail/System.Web.Mail.SmtpMail
framework, no matter what encoding parameter i use.
Thanks, anyway -----Original Message----- Try to use encoding parameter in MailAttachment
constructor.
"Trond A. S. Andersen" <ts*@scandpower.no> wrote in
messagenews:08****************************@phx.gbl... Hi, all!
I'm trying to use the System.Web.Mail. "package"
combinded with System.Web.Mail.SmtpMail in order to send MS Excel spreadsheets attached to mail messages. However, sending one single spreadsheet attachment per message, seems to
be causing som kind of corruption of the attachment, while several spreadsheets per works just fine. Consider the following three snippets of C# code:
// Sample 1 ->
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage(); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_spreadsheet.xls")); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_other_spreadsheet.xls"));
msg.From = "me@mydomain.com; msg.To = "so*****@somewhere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail.SmtpMail.SmtpServer
= "some_smtp_server"; System.Web.Mail.SmtpMail.Send(msg);
// Sample 2 ->
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage(); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_spreadsheet.xls"));
msg.From = "me@mydomain.com; msg.To = "so*****@somewhere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail.SmtpMail.SmtpServer
= "some_smtp_server"; System.Web.Mail.SmtpMail.Send(msg);
// Sample 3 ->
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage(); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_other_spreadsheet.xls"));
msg.From = "me@mydomain.com; msg.To = "so*****@somewhere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail.SmtpMail.SmtpServer
= "some_smtp_server"; System.Web.Mail.SmtpMail.Send(msg);
Using the code in Sample 1, both attatchments can be opened by Excel without any problem, as they arrive at
the receiving end.
Using the code in Sample 2 or Sample 3, however, NEITHER of the attachments, which happens to be the EXACT same
two Excel spreadsheets as in Sample1, can be opened by the receipient using Excel. Any ettemt two open them results in either a "The document is corrupt and cannot be
opened. To try an repair..." error message or a " cannot be accessed. The file may be read-only, or..." error message. If any of you have an idea what's causing this problem, and maybe even a suggestion for a workaround, your reply would be highly appreciated.
Regards, Trond
.
Tried that. Excel spreadsheet attachments somehow
corrupted by the System.Web.Mail/System.Web.Mail.SmtpMail
framework, no matter what encoding parameter i use.
Thanks, anyway -----Original Message----- Try to use encoding parameter in MailAttachment
constructor.
"Trond A. S. Andersen" <ts*@scandpower.no> wrote in
messagenews:08****************************@phx.gbl... Hi, all!
I'm trying to use the System.Web.Mail. "package"
combinded with System.Web.Mail.SmtpMail in order to send MS Excel spreadsheets attached to mail messages. However, sending one single spreadsheet attachment per message, seems to
be causing som kind of corruption of the attachment, while several spreadsheets per works just fine. Consider the following three snippets of C# code:
// Sample 1 ->
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage(); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_spreadsheet.xls")); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_other_spreadsheet.xls"));
msg.From = "me@mydomain.com; msg.To = "so*****@somewhere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail.SmtpMail.SmtpServer
= "some_smtp_server"; System.Web.Mail.SmtpMail.Send(msg);
// Sample 2 ->
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage(); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_spreadsheet.xls"));
msg.From = "me@mydomain.com; msg.To = "so*****@somewhere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail.SmtpMail.SmtpServer
= "some_smtp_server"; System.Web.Mail.SmtpMail.Send(msg);
// Sample 3 ->
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage(); msg.Attachments.Add(new System.Web.Mail.MailAttachment ("some_other_spreadsheet.xls"));
msg.From = "me@mydomain.com; msg.To = "so*****@somewhere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail.SmtpMail.SmtpServer
= "some_smtp_server"; System.Web.Mail.SmtpMail.Send(msg);
Using the code in Sample 1, both attatchments can be opened by Excel without any problem, as they arrive at
the receiving end.
Using the code in Sample 2 or Sample 3, however, NEITHER of the attachments, which happens to be the EXACT same
two Excel spreadsheets as in Sample1, can be opened by the receipient using Excel. Any ettemt two open them results in either a "The document is corrupt and cannot be
opened. To try an repair..." error message or a " cannot be accessed. The file may be read-only, or..." error message. If any of you have an idea what's causing this problem, and maybe even a suggestion for a workaround, your reply would be highly appreciated.
Regards, Trond
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Trond A. S. Andersen |
last post by:
Hi, all!
I'm trying to use the System.Web.Mail. "package" combinded
with System.Web.Mail.SmtpMail in order to send MS Excel
spreadsheets attached to mail messages. However, sending
one single...
|
by: Chris Thunell |
last post by:
I'm using the system.web.mail in vb.net to send emails out in a vb.net
application. The sending of emails works great. Is there a way to have it
send me back a delivery receipt or a read receipt?...
|
by: Brian Farnhill (MCP VB.NET) |
last post by:
Hi,
I am having some trouble using the MailMessage object to send an email with
more than one attachment.
I am working on a web based application where a user can submit information,
along...
|
by: theWizard1 |
last post by:
The following sends my email, but the attachment is empty. The attachment
should contain the data that is in the string that was created from the
xmlReader.
I have a stored procedure written...
|
by: Brad |
last post by:
I have a web .Net app which sends emails with attachments. After the email
is sent I clean up aftermyself and delete the attachments from disk. In
upgrading to .Net 2 I changed the email logic...
|
by: David C |
last post by:
I would like to have an email go to 2 email addresses but when I try it by
separating with semicolon or comma it fails. Can anyone help? below is my
code (see ToAddress string). Thanks.
David...
|
by: =?Utf-8?B?SmltSm9i?= |
last post by:
Hi All,
I am using c# to build an application. I want a button that will be able to
open a new mail message with an attachment. The new mail message works but I
can't get the attachment to work...
|
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...
|
by: Prefers Golfing |
last post by:
We are having to extend the System.Net.Mail namespace and need some help
with coding it.
We have added several properties to System.Net.Mail.Attachment and need to
add our several of them to...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |