如何通过电子邮件中的表格发送数据? [英] How to send data through table in email ?

查看:497
本文介绍了如何通过电子邮件中的表格发送数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发送邮件然后发送表像这样td>你好





但是我需要喜欢---你好

不是桌子结构..



我尝试过:



i am sending Mail Then Send Table like this td>Hello



But I Need like ---Hello
Not table Structure..

What I have tried:

MailAddress to = new MailAddress(email);
                //sender email address
                MailAddress from = new MailAddress("xyz@gmail.com.com");

                MailMessage msg = new MailMessage();
                //use reason shown in grid
                msg.Subject = "Hello This For Test";



               string textBody = "<table border=" + 1 + " cellpadding=" + 0 + " cellspacing=" + 0 + " width=" + 400 + "><tbody><tr><td>Name:'"+name.Text+"'</td> <td> Email:'"+email+"'  </td><td>ContactNo:'"+contactNo.Text+"'</td></tr></tbody></table>";
                msg.Body = textbody;
                msg.From = from;
                msg.To.Add(to);

            SmtpClient client = new SmtpClient();
        client.Host = "smtpout.secureserver.net";
        client.Port = 25;
        client.EnableSsl = true;
        client.Credentials = new System.Net.NetworkCredential("xyz@gmail.com", "01234");

        try
        {
            client.Send(mail);
        }
        catch (Exception ex)
        {
            Console.WriteLine("{0} Exception caught.", ex);
        }

推荐答案

如果您正在使用System.Web.Mail程序集尝试使用System.Net.Mail它有一个选项将邮件正文设置为HTML。



If you are using System.Web.Mail Assembly try using System.Net.Mail it has a option to set your message body as HTML.

MailMessage msg = new MailMessage();
msg.IsBodyHTML=true;


这篇关于如何通过电子邮件中的表格发送数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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