本文介绍了从infopath表单自动发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
请从infopath表单发送用于自动发送邮件的代码.发送邮件时,我需要避免conopation弹出窗口.
Hi flokes,
please send code for automatic mail sending from infopath form . i need to avoid confromation popup window while sending mail
推荐答案
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.mailservername.com");
mail.From = new MailAddress("[email protected]");
mail.To.Add("serndermailid");
mail.Subject = "subject";
mail.Body = "mail body";
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment("you attachment file path");
mail.Attachments.Add(attachment);
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
//optional for checking
MessageBox.Show("mail Send");
}
catch (Exception ex)
{
//optional for checking
MessageBox.Show("mail sending fail");
}
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.mailservername.com");
mail.From = new MailAddress("[email protected]");
mail.To.Add("sendermailid");
mail.Subject = "subject";
mail.Body = "mail body";
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment("you attachment file path");
mail.Attachments.Add(attachment);
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
//optional for checking
MessageBox.Show("mail Send");
}
catch (Exception ex)
{
//optional for checking
MessageBox.Show("mail sending fail");
}
这篇关于从infopath表单自动发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!