English 中文(简体)
发送多个带有图像的邮件
原标题:send multiple mail with image attachements
  • 时间:2011-06-08 11:11:12
  •  标签:
  • c#
  • email

i am using mail class to send email with attachment as image to multiple recipients. but the problem is as email is sent to first recipient it is throwing an exception that "image is being used by another process".. how this can be solved..

i am getting users in listitem as:

 foreach (ListItem item in lstboxlist.Items)
                {
                    to = Convert.ToString(item);
                    select_theme_tosend(to, sub);
                }

and i am sending mail to users as:

string source_theme =  theme;
            string dest_theme_path = "xxx";

            if (File.Exists(dest_theme_path))
            {
                File.Delete(dest_theme_path);
            }
            File.Copy(source_theme, dest_theme_path);
            xmlDoc.Load(theme);
            XmlNode node = null;
            SendMail_Html send_html = new SendMail_Html ();

                MailMessage mail = new MailMessage();
                Attachment footer_att = null;
                Attachment header_att = null;
                Attachment other_att = null;
                mail.Attachments.Add(other_att);
                }
                xmlDoc.Save(theme);

                StreamReader strm_rdr = new StreamReader(theme);
                string theme_text = strm_rdr.ReadToEnd();

                SendMail send_mail = new SendMail();
                send_html.sent_htmlmail1(to, theme_text, subject, footer_att, header_att, other_att);
                mail.Dispose();
               // File.Delete(header_path);
               // File.Delete(other_imagepath);
               // File.Delete(foot_image_path);  
}  

if i uncomment last line it is showing an error on sending mail to second address as: "specified file cannot found"... what should i do to send multiple emails... please help...

最佳回答

Close the stream after you ve finished with it, so for example:

StreamReader strm_rdr = new StreamReader(theme);
string theme_text = strm_rdr.ReadToEnd();
strm_rdr.Close();
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签