从infopath表单自动发送邮件 [英] Automatic maill sending from infopath form

查看:193
本文介绍了从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

推荐答案

以下代码可能会对您有所帮助
The following code might help you
try
            {

                MailMessage mail = new MailMessage();

                SmtpClient SmtpServer = new SmtpClient("smtp.mailservername.com");

                mail.From = new MailAddress("username@mailserver.com");

                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("username@mailserver.com", "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");

            }


以下代码可能会对您有所帮助
The following code might help you
try
            {

                MailMessage mail = new MailMessage();

                SmtpClient SmtpServer = new SmtpClient("smtp.mailservername.com");

                mail.From = new MailAddress("username@mailserver.com");

                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("username@mailserver.com", "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");

            }


thaks很好,但是我只需要离线发送邮件,这样我就不能使用smtp
thaks , its work fine but i need to send mails in offline only so i can''t use smtp


这篇关于从infopath表单自动发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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