按钮点击自动发送电子邮件 [英] send email automatically in button click

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

问题描述

之前我正在尝试以单独的形式发送邮件

但现在我想在相应的电子邮件地址中自动发送邮件..



管理员批准/拒绝文件现在我想添加

当管理员批准/拒绝任何文件,然后相应的文件名和管理员选择的值(如批准/拒绝)发送到他/她的邮件..以前我通过代码使用sepearte表单发送邮件是

previously i am trying to send mails in separate form
but now i want to send mail automatically in respective email address..

Admin approve/reject documents now i want to add
when admin approve/reject any documents then respective document name and the value which admin select (like approve /reject ) send to his/her mail ... previously i send mail using sepearte form through code is

protected void btnSendMail_Click(object sender, EventArgs e)
    {
        string connStr =
            ConfigurationManager.ConnectionStrings["mydms"].ConnectionString;
        SqlConnection mySQLconnection = new SqlConnection(connStr);
        string empId = string.Empty;
        DataTable dt = new DataTable();


        try
        {
            mySQLconnection.Open();
            for (int i = 0; i < Repeateremail.Items.Count; i++)
            {

                CheckBox checkboc =
                 ((CheckBox)Repeateremail.Items[i].FindControl("chkSelect"));
                if (checkboc != null)
                {

                    if (checkboc.Checked == true)
                    {

                        //get Current EMAIL_ID from the DataKey

                        string emailId =
                  ((Label)Repeateremail.Items[i].FindControl("lbl_email")).Text;
                        //write code to send mail
                        SendEmailUsingGmail(emailId);
                        dt.Clear();
                        dt.Dispose();
                    }
                    else if (checkboc.Checked == false)
                    {
                    }
                }
            }

        }


        catch (Exception ex)
        {
            emailsent.Text="Failed";
        }
        finally
        {
            empId = string.Empty;
        }
    }





以上代码我通过复选框发送邮件给管理员检查复选框然后点击发送邮件然后邮件发送,但现在我想要当管理员批准文件,然后这个相应的文件名称和价值发送到他/她的邮件。

http://i.stack.imgur.com/9tGh7.png [ ^ ]

推荐答案

您好


您可以编写Windows服务,以指定的间隔或时间自动发送邮件。

许多教程可用于创建窗口服务。





请参考以下链接



http://code.msdn.microsoft .com / windowsdesktop / Notification-Service-A-adf433b7 [ ^ ]



请将其标记为答案,如果它可以解决您的问题。
Hi

You can write a windows service to send mail automatically at a specified interval or time .
Many tutorials are available to create a window service .


Pls refer the following link

http://code.msdn.microsoft.com/windowsdesktop/Notification-Service-A-adf433b7[^]

Pls mark it as answer if it resolves your problem .


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

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