473,378 Members | 1,309 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,378 software developers and data experts.

What is wrong here?

Hi, friends,

I have a function which send email with attachments as the follows:

public int SendEmailWithAttachment(string fromEmailAddress,
string toEmailAddress, string subject, string message, string attachment)
{
System.Web.Mail.MailMessage mm = new System.Web.Mail.MailMessage();
mm.From = fromEmailAddress;
mm.To = toEmailAddress;
mm.Subject = subject;
mm.Body = message;
mm.BodyFormat = System.Web.Mail.MailFormat.Text;
mm.Priority = System.Web.Mail.MailPriority.Normal;
mm.BodyEncoding = System.Text.Encoding.Default;
mm.UrlContentBase = "";
mm.UrlContentLocation = "";

if (attachment.Trim() != "")
{
char[] delim = new char[] {','};
foreach (string sSubstr in attachment.Split(delim))
{
System.Web.Mail.MailAttachment ma = new
System.Web.Mail.MailAttachment(sSubstr);
mm.Attachments.Add(ma);
}
}

System.Web.Mail.SmtpMail.SmtpServer = ""; //default
System.Web.Mail.SmtpMail.Send(mm);
return 1;
}

It works fine if there is only one attachment file. However, if there are
two or more files, I got an error saying:
Could not access 'CDO.Message' object.

But, I really could not find what was wrong. Any ideas, suggestions, etc.?
Thanks a lot.

Nov 21 '05 #1
3 2256
wrong group!

"Andrew" <An****@discussions.microsoft.com> wrote in message
news:B2**********************************@microsof t.com...
Hi, friends,

I have a function which send email with attachments as the follows:

public int SendEmailWithAttachment(string fromEmailAddress,
string toEmailAddress, string subject, string message, string attachment)
{
System.Web.Mail.MailMessage mm = new System.Web.Mail.MailMessage();
mm.From = fromEmailAddress;
mm.To = toEmailAddress;
mm.Subject = subject;
mm.Body = message;
mm.BodyFormat = System.Web.Mail.MailFormat.Text;
mm.Priority = System.Web.Mail.MailPriority.Normal;
mm.BodyEncoding = System.Text.Encoding.Default;
mm.UrlContentBase = "";
mm.UrlContentLocation = "";

if (attachment.Trim() != "")
{
char[] delim = new char[] {','};
foreach (string sSubstr in attachment.Split(delim))
{
System.Web.Mail.MailAttachment ma = new
System.Web.Mail.MailAttachment(sSubstr);
mm.Attachments.Add(ma);
}
}

System.Web.Mail.SmtpMail.SmtpServer = ""; //default
System.Web.Mail.SmtpMail.Send(mm);
return 1;
}

It works fine if there is only one attachment file. However, if there are
two or more files, I got an error saying:
Could not access 'CDO.Message' object.

But, I really could not find what was wrong. Any ideas, suggestions, etc.?
Thanks a lot.

Nov 21 '05 #2
Could you please tell me more, I am not sure I understand...
Thanks.

"Dino Chiesa [Microsoft]" wrote:
wrong group!

"Andrew" <An****@discussions.microsoft.com> wrote in message
news:B2**********************************@microsof t.com...
Hi, friends,

I have a function which send email with attachments as the follows:

public int SendEmailWithAttachment(string fromEmailAddress,
string toEmailAddress, string subject, string message, string attachment)
{
System.Web.Mail.MailMessage mm = new System.Web.Mail.MailMessage();
mm.From = fromEmailAddress;
mm.To = toEmailAddress;
mm.Subject = subject;
mm.Body = message;
mm.BodyFormat = System.Web.Mail.MailFormat.Text;
mm.Priority = System.Web.Mail.MailPriority.Normal;
mm.BodyEncoding = System.Text.Encoding.Default;
mm.UrlContentBase = "";
mm.UrlContentLocation = "";

if (attachment.Trim() != "")
{
char[] delim = new char[] {','};
foreach (string sSubstr in attachment.Split(delim))
{
System.Web.Mail.MailAttachment ma = new
System.Web.Mail.MailAttachment(sSubstr);
mm.Attachments.Add(ma);
}
}

System.Web.Mail.SmtpMail.SmtpServer = ""; //default
System.Web.Mail.SmtpMail.Send(mm);
return 1;
}

It works fine if there is only one attachment file. However, if there are
two or more files, I got an error saying:
Could not access 'CDO.Message' object.

But, I really could not find what was wrong. Any ideas, suggestions, etc.?
Thanks a lot.


Nov 21 '05 #3
you are posting to the wrong newsgroup.
If I am not mistaken, you are asking about System.Web.Mail, and CDO;
this newsgroup covers webservices.

I suggest something like
microsoft.public.dotnet.framework
a more general group.

-D

"Andrew" <An****@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
Could you please tell me more, I am not sure I understand...
Thanks.

"Dino Chiesa [Microsoft]" wrote:
wrong group!

"Andrew" <An****@discussions.microsoft.com> wrote in message
news:B2**********************************@microsof t.com...
> Hi, friends,
>
> I have a function which send email with attachments as the follows:
>
> public int SendEmailWithAttachment(string
> fromEmailAddress,
> string toEmailAddress, string subject, string message, string
> attachment)
> {
> System.Web.Mail.MailMessage mm = new System.Web.Mail.MailMessage();
> mm.From = fromEmailAddress;
> mm.To = toEmailAddress;
> mm.Subject = subject;
> mm.Body = message;
> mm.BodyFormat = System.Web.Mail.MailFormat.Text;
> mm.Priority = System.Web.Mail.MailPriority.Normal;
> mm.BodyEncoding = System.Text.Encoding.Default;
> mm.UrlContentBase = "";
> mm.UrlContentLocation = "";
>
> if (attachment.Trim() != "")
> {
> char[] delim = new char[] {','};
> foreach (string sSubstr in attachment.Split(delim))
> {
> System.Web.Mail.MailAttachment ma = new
> System.Web.Mail.MailAttachment(sSubstr);
> mm.Attachments.Add(ma);
> }
> }
>
> System.Web.Mail.SmtpMail.SmtpServer = ""; //default
> System.Web.Mail.SmtpMail.Send(mm);
> return 1;
> }
>
> It works fine if there is only one attachment file. However, if there
> are
> two or more files, I got an error saying:
> Could not access 'CDO.Message' object.
>
> But, I really could not find what was wrong. Any ideas, suggestions,
> etc.?
> Thanks a lot.
>
>
>


Nov 21 '05 #4

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

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
17
by: Paul | last post by:
HI! I get an error with this code. <SCRIPT language="JavaScript"> If (ifp==""){ ifp="default.htm"} //--></SCRIPT> Basicly I want my iframe to have a default page if the user enters in...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
28
by: Madhur | last post by:
Hello what about this nice way to open a file in single line rather than using if and else. #include<stdio.h> void main() { FILE *nd; clrscr();...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
3
by: Siong.Ong | last post by:
Dear all, my PHP aims to update a MySQL database by selecting record one by one and modify then save. Here are my PHP, but I found that it doesnt work as it supposed to be, for example, when...
38
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - What books cover EcmaScript? ----------------------------------------------------------------------- Most CLJ...
16
by: John Doe | last post by:
Hi, I wrote a small class to enumerate available networks on a smartphone : class CNetwork { public: CNetwork() {}; CNetwork(CString& netName, GUID netguid): _netname(netName),...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
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...

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.