在C#项目中发送电子邮件 [英] send e mail in c# project
本文介绍了在C#项目中发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们正在做房地产项目,我们希望能帮助您将邮件发送给clientrequests:我们正在使用asp.netlaugh:
hai we are doing real estate project and we heed help for sending mails to the clientrequests :we are using asp.netlaugh:
推荐答案
从 ^ ]
...或修改此内容:
...or modify this:
using System;
using System.Web.Mail;
namespace WebMail
{
class Class1
{
static void Main(string[] args)
{
try
{
MailMessage oMsg = new MailMessage();
// TODO: Replace with sender e-mail address.
oMsg.From = "sender@somewhere.com";
// TODO: Replace with recipient e-mail address.
oMsg.To = "recipient@somewhere.com";
oMsg.Subject = "Send Using Web Mail";
// SEND IN HTML FORMAT (comment this line to send plain text).
oMsg.BodyFormat = MailFormat.Html;
// HTML Body (remove HTML tags for plain text).
oMsg.Body = "<HTML><BODY><B>Hello World!</B></BODY></HTML>";
// ADD AN ATTACHMENT.
// TODO: Replace with path to attachment.
String sFile = @"C:\temp\Hello.txt";
MailAttachment oAttch = new MailAttachment(sFile, MailEncoding.Base64);
oMsg.Attachments.Add(oAttch);
// TODO: Replace with the name of your remote SMTP server.
SmtpMail.SmtpServer = "MySMTPServer";
SmtpMail.Send(oMsg);
oMsg = null;
oAttch = null;
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}
}
}
}
嗨 您可以参考这篇文章:
使用System.Web.Mail命名空间发送邮件
Hi You can refer to this article:
Send mail using System.Web.Mail namespace
这篇关于在C#项目中发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文