发送带有ListBox内容的邮件 [英] Sending Mail with ListBox Content

查看:85
本文介绍了发送带有ListBox内容的邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我:


我想发送在邮件正文中具有列表框问题的邮件

Please Help me:


I want to send mail which have Listbox matter in message body

try
           {
               const string SERVER = "relay-hosting.secureserver.net";
               MailMessage oMail = new System.Web.Mail.MailMessage();
               oMail.From = "admin@Domain.com";
               oMail.To = "abc@gmail.com";
               oMail.Subject = "hello";
               oMail.BodyFormat = MailFormat.Html; // enumeration
               oMail.Priority = MailPriority.High; // enumeration
               oMail.Body = "List is here - " + ListBox1.Items.ToString() + DateTime.Now;
               SmtpMail.SmtpServer = SERVER;
               SmtpMail.Send(oMail);
               oMail = null;
           }
           catch (Exception emsg)
           {

           }




但是如果我使用文本框,则它不适用于列表框,然后它会起作用

谁能解释为什么?




But it is not working with Listbox if i take textbox then it works

can anyone explain why ???

推荐答案

您需要遍历ListBox中的项目并将每个项目附加到oMail.Body.另外,请很好地格式化列表项.

You need to iterate through the items in the ListBox and append each item to oMail.Body. Also, format the list items nicely.

String list = String.Empty;
for (int i = 0; i < ListBox1.Items.Count; ++i)
{
 list += ListBox1.Items[i].ToString() + "\n";
}


查看以下链接以获取所需的解决方案:

http://mywsat.codeplex.com/
check out the below link for your required solution :

http://mywsat.codeplex.com/


这篇关于发送带有ListBox内容的邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆