472,985 Members | 2,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Sending Multiple Attachement in a Mail

Hi

I am beginner to C Sharp. trying to attach a multiple files to a mail.

I can attach a single file or i can create multiple object of an Attachment class and add to a mail attachment object.

But when i want to do it dynamically to attach multiple file...say my code might be generating one or more files depending on the result set...

I have a temporary variable will keep track of no. of attachments and their path.

Only problem I am facing is to add the files to attachment class dynamically...

Any tips or an example in this will be of grt help to me....

Thanks
Apr 12 '08 #1
2 2647
nateraaaa
663 Expert 512MB
Which version of the .NET framework are you using?

Nathan
Apr 14 '08 #2
Plater
7,872 Expert 4TB
So couldn't you just keep creating/adding attachments?
I am not seeing what the problem is, you said you were able to add multiple attachment objects?

Here is an email with 4 text attachments and 10 jpeg attachments
Expand|Select|Wrap|Line Numbers
  1. MailMessage m = new MailMessage("from@me", "to@me", "this is the subject", "File(s) attached");
  2. m.Attachments.Add(Attachment.CreateAttachmentFromString("here is a text attachment", "text/plain"));
  3. m.Attachments.Add(Attachment.CreateAttachmentFromString("and another text attachment", "text/plain"));
  4. m.Attachments.Add(Attachment.CreateAttachmentFromString("still more text attachments", "text/plain"));
  5. m.Attachments.Add(Attachment.CreateAttachmentFromString("and another text attachment", "text/plain"));
  6. for (int i = 0; i < 10; i++)
  7. {
  8.     Attachment a = new Attachment("mypic" + i.ToString() + ".jpg", "image/jpeg");
  9.     m.Attachments.Add(a);
  10. }
  11.  
Apr 14 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Roy G. Vervoort | last post by:
With them help of newsgroups I created a form that makes it possible to sent an email with an attachement thats on the internet.. How can i attache a file thats on the users harddrive? this...
5
by: Olivier/Noetika | last post by:
would like to send messages from my vb application with the user default mail software. That's to say preparing content, attachement and let user selecting the "to" option with it's own friends list....
2
by: Malik Asif Joyia | last post by:
Hello how can i send a stream object (a file stream returned from SQL Reporting Service) as a mail attachement. i dont want to write this file to the disk Thanks
6
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
5
by: Jai | last post by:
Hi, I am in a problem of sending mass emails(newsletter) to my website members. Actually my problem is this: I want to send newsletter to my website members. But I had given a facility for...
1
by: Dreea | last post by:
Hy all.... I tried several functions found on the internet and i don't seem to figure what the problem is... this is one of the example i tryied function sendMail($sendto, $subject, $message,...
6
by: electroon | last post by:
Hi Frnds, I have a task in my project wherein i have to send out a mail from my C++ code.With some file attachements.Please help me in this. At a higher level wat i can tell is my code...
7
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to...
0
by: ramab | last post by:
hi, i'm a bit stuck here in sending emails to multiple users which i need to read from a database. With codes below, i able only to send 2 recipients. any idea how to send to multiple users? thx...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.