public static void sendEmail(string toAddress
{
var fromAddress = ConfigurationManager
string fromPassword = ConfigurationManager
const string subject = "Job Recommendation";
var smtp = new SmtpClient
{
Host = ConfigurationManager
Port = int
EnableSsl = true
DeliveryMethod = SmtpDeliveryMethod
UseDefaultCredentials = false
Credentials = new NetworkCredential(fromAddress
};
using (var message = new MailMessage(fromAddress
{
smtp
}
}
<add key="EmailAddress" value="**********@gmail
<add key="EmailPassword" value="*********"/> //Emial PWD
<add key="SmtpServer" value="smtp
<add key="SmtpPort" value="
<
var fromAddress = "allenyinj@gmail
string fromPassword = "yj
const string subject = "CV";
var smtp = new SmtpClient
{
Host = "smtp
Port =
EnableSsl = true
DeliveryMethod = SmtpDeliveryMethod
UseDefaultCredentials = false
Credentials = new NetworkCredential(fromAddress
};
MailMessage email=new MailMessage(fromAddress
email
email
string attachmentPath = "C:
Attachment inline = new Attachment(attachmentPath);
inline
inline
//inline
//inline
inline
email
email
smtp
email
//如果沒有路徑
Attachment letter = new Attachment(FileUploadLetter
letter
letter
//inline
letter
letter
letter
From:http://tw.wingwit.com/Article/program/net/201311/14379.html