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_spreadsh eet.xls"));
msg.Attachments .Add(new System.Web.Mail .MailAttachment
("some_other_sp readsheet.xls") );
msg.From = "me@mydomain.co m;
msg.To = "so*****@somewh ere.com";
msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail .SmtpMail.SmtpS erver = "some_smtp_serv er";
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_spreadsh eet.xls"));
msg.From = "me@mydomain.co m;
msg.To = "so*****@somewh ere.com";
msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail .SmtpMail.SmtpS erver = "some_smtp_serv er";
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_sp readsheet.xls") );
msg.From = "me@mydomain.co m;
msg.To = "so*****@somewh ere.com";
msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail .SmtpMail.SmtpS erver = "some_smtp_serv er";
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 8681
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_spreadsh eet.xls")); msg.Attachments .Add(new System.Web.Mail .MailAttachment ("some_other_sp readsheet.xls") );
msg.From = "me@mydomain.co m; msg.To = "so*****@somewh ere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail .SmtpMail.SmtpS erver = "some_smtp_serv er"; 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_spreadsh eet.xls"));
msg.From = "me@mydomain.co m; msg.To = "so*****@somewh ere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail .SmtpMail.SmtpS erver = "some_smtp_serv er"; 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_sp readsheet.xls") );
msg.From = "me@mydomain.co m; msg.To = "so*****@somewh ere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail .SmtpMail.SmtpS erver = "some_smtp_serv er"; 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_spreadsh eet.xls")); msg.Attachments .Add(new System.Web.Mail .MailAttachment ("some_other_sp readsheet.xls") );
msg.From = "me@mydomain.co m; msg.To = "so*****@somewh ere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail .SmtpMail.SmtpS erver = "some_smtp_serv er"; 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_spreadsh eet.xls"));
msg.From = "me@mydomain.co m; msg.To = "so*****@somewh ere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail .SmtpMail.SmtpS erver = "some_smtp_serv er"; 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_sp readsheet.xls") );
msg.From = "me@mydomain.co m; msg.To = "so*****@somewh ere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail .SmtpMail.SmtpS erver = "some_smtp_serv er"; 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_spreadsh eet.xls")); msg.Attachments .Add(new System.Web.Mail .MailAttachment ("some_other_sp readsheet.xls") );
msg.From = "me@mydomain.co m; msg.To = "so*****@somewh ere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail .SmtpMail.SmtpS erver
= "some_smtp_serv er"; 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_spreadsh eet.xls"));
msg.From = "me@mydomain.co m; msg.To = "so*****@somewh ere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail .SmtpMail.SmtpS erver
= "some_smtp_serv er"; 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_sp readsheet.xls") );
msg.From = "me@mydomain.co m; msg.To = "so*****@somewh ere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail .SmtpMail.SmtpS erver
= "some_smtp_serv er"; 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_spreadsh eet.xls")); msg.Attachments .Add(new System.Web.Mail .MailAttachment ("some_other_sp readsheet.xls") );
msg.From = "me@mydomain.co m; msg.To = "so*****@somewh ere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail .SmtpMail.SmtpS erver
= "some_smtp_serv er"; 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_spreadsh eet.xls"));
msg.From = "me@mydomain.co m; msg.To = "so*****@somewh ere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail .SmtpMail.SmtpS erver
= "some_smtp_serv er"; 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_sp readsheet.xls") );
msg.From = "me@mydomain.co m; msg.To = "so*****@somewh ere.com"; msg.Subject = "TWO Excel spreadsheets attached;
System.Web.Mail .SmtpMail.SmtpS erver
= "some_smtp_serv er"; 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 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:
|
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? (I think i prefer
delivery receipt)
Any help would be greatly appreciated!
Chris Thunell
cthunell@pierceassociates.com
mycode currently is the following:
|
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 with a number of files. The information, including the file is stored
in the database, and an email is sent with the information and any files that
were submitted are attached. The system works fine when a user makes a
submission that has no...
|
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 using For XML explicit, and it returns an
xml reader. Then the following:
xmlRdr.MoveToContent();
string myTemp = xmlRdr.ReadOuterXml();
|
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 from using system.web.mail to
system.net.mail (of course vs is telling me system.web.mail is obsolete).
In .Net 1.1, the files deleted with no problem but in .Net 2 when I attempt
to delete I receive
The process cannot access the file ...'...
| |
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
strUser = UtilClass.GetUserName(strUser)
'!!! UPDATE THIS VALUE TO YOUR EMAIL ADDRESS
Const ToAddress As String = "me@myemail.com"
Const FromAddress As String = "me@myemail.com"
|
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 - there is no error message just no
attachment. Any ideas? Code i am using is;
System.Diagnostics.Process.Start("mailto:email@email.com?subject=Software&body=see attachment&attachment=c:/myview.mht");
Thanks
|
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 appropriate dotnet forum.
Now what I wish is the ability to send bcc's rather than to: (would be...
|
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 System.Net.Mail.MailMessage.Attachments.
// public AttachmentCollection Attachments { get; }
How do we override AttachmentCollection to be a collection of
OurNamespace.Attachments?
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |