如何在通过C#发送的电子邮件中发送变量值 [英] how to send variable value in email send through C#
本文介绍了如何在通过C#发送的电子邮件中发送变量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我陷入了奇怪的问题,我试图发送变量值(我有
通过.cs文件计算得出)通过邮件发送给各个人,邮件也从后面的代码发送出去.
可能吗 ?如果可以,请告诉我如何?
谢谢
PArth
i am stuck in weird issue , i am trying to send variable value (which i have
calculated in .cs file )to various people through mail which is also send from code behind.
Is it possible ? if yes can you please tell me how ??
Thanks
PArth
推荐答案
是.
基本电子邮件很简单:在C#中使用或没有附件:通用例程. [ ^ ]
在其中,您可以将变量值作为文本发送,也可以序列化值(例如,使用 ^ ]),并在需要计算机阅读而不是人类的情况下将其作为附件发送.
Yes.
The basic email is simple: Sending an Email in C# with or without attachments: generic routine.[^]
Within that, you can send the variable value as text, or you could serialize the value (using for example the XmlSerializer[^]) and send it as an attachment if you need to be able to computer read it rather than human.
try
{
MailMessage mail = new MailMessage();
mail.To.Add("anzaman_edi@yahoo.com");
mail.To.Add("shi01715@yahoo.com");
mail.From = new MailAddress("shishir64092@gmail.com");
mail.Subject = "Send Email by asp.net code using google or gmail smtp server";
string Body = "Hi"+USERNAME+ ", I am testing Email function in asp.net" +
"using google or gmail smtp server";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
("shishir64092@gmail.com", "abcdef");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
在您的邮件body
中,您可以设置参数!
in your mail body
you can set your params!
谢谢.......................... ..................................
Thanks............................................................
这篇关于如何在通过C#发送的电子邮件中发送变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文