mail.Attachments (Multiple Attachments) from Querystring

Joined
May 4, 2009
Messages
1
Reaction score
0
Can someone please help me with an issue I am having with sending emails using System.Net.Mail; I am passing in the querystring 1 image and it attaches fine but now I need to be able to have multiple attachments in the email that come from the querystring as separated values.

-- Works fine
string tmpNewFile = Request.QueryString["tmpNewFile"];
mail.Attachments.Add(new Attachment(tmpNewFile));

-- Example URL with querystring tmpNewFile and 1 image
?tmpNewFile=image1.jpg

-------------------------------------------------------------------
-- I want to be able to add multiple attachments that come from the querystring but don't know how to do it? The will be passed in the querystring this way with a ; but I can change it if needed.

?tmpNewFile=image1_.jpg; image2_.jpg

-------------------------------------------------------------------
-- I saw this on the internet but don't know if it will work for me and if so how I would implement it to work the way I need to.

ICollection<System.Net.Mail.Attachment> attachments

foreach (string str in myattach)
{
if (str.Trim() != "")
{
mail.Attachments.Add(new Attachment(Path.GetFullPath(str)));

}
}

if (attachments != null)
{
foreach (System.Net.Mail.Attachment att in attachments)
{
mail.Attachments.Add(att);
}
-------------------------------------------------------------------
Any help would be greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,058
Members
48,769
Latest member
Clifft

Latest Threads

Top