电子邮件提醒 [英] EMAIL ALERTS

查看:82
本文介绍了电子邮件提醒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的C#桌面应用程序上添加一个电子邮件警报. vs2008广告中有我正在运行的附件,我不知道从哪里开始!

I want to add an Email alert on my C# desktop application. I have the apllication running in my vs2008 ad I don't know where to start from!! Plz Folks Help me!!

推荐答案

是否要在程序运行时发送电子邮件,否则必须开发Windows服务.

您可以使用以下方法.

但是我的建议是,不是每个客户端都管理自己的电子邮件交易,而是每个客户端编写邮件信息,这些信息将发送到服务器上的sql表(如果有),并发送Windows服务以指定的间隔发送邮件.此方法更易于管理且易于维护.

这里是方法.

Do you want the emails sent while program is running otherwise you have to develop a Windows Service.

You can use the following method.

But my advise is instead of each client managing it's own email transactions, each client writes mail information which will be sent to a sql table on server(if available) and a windows service sends mails with specified intervals. This method is more manageble and easier to maintain.

Here is the method.

        public void SendMail(string smtpAddress, string from,string to, string cc, string bcc, string body, string subject, bool isHtml,string attachmentFileNames)
        {
            SmtpClient insSmtpClient = new SmtpClient(smtpAddress);
            MailMessage insMailMessage = new MailMessage();
            insMailMessage.From = new MailAddress(from);
            foreach (string strBcc in bcc.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
            {
                insMailMessage.Bcc.Add(strBcc);
            }
            foreach (string strTo in to.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
            {
                insMailMessage.To.Add(strTo);
            }
            foreach (string strCc in cc.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
            {
                insMailMessage.CC.Add(strCc);
            }
            insMailMessage.Body = body;
            insMailMessage.Subject = subject;
            insMailMessage.IsBodyHtml = isHtml;
 
            foreach (string strAtt in attachmentFileNames.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
            {
                insMailMessage.Attachments.Add(new Attachment(strAtt));
            }
            insSmtpClient.Send(insMailMessage);
        }



这篇关于电子邮件提醒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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