473,395 Members | 1,972 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,395 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 2671
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
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,...
0
jinu1996
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...
0
agi2029
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,...

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.