Member 12954126 Ответов: 3

Как отправить запрос на веб-страницу, нажав на изображение в gmail?


Я создал одну страницу веб-формы, в которой у меня есть 2 кнопки "одобрить" и "отклонить", после нажатия на кнопку почта отправлена пользователю.

Мой вопрос заключается в том, что если я хочу поместить 2 изображения или кнопки с именами "одобрить" и "отклонить" в тело электронной почты, и на событие щелчка этой кнопки или изображения, я хочу снова отправить запрос на событие щелчка кнопки веб-страницы, которую я создал первым.
Я поставил свою форму за кодом ниже, пожалуйста, помогите мне получить код записи...

protected void lnbtn_Approve_Click(object sender, EventArgs e)
{
    LinkButton lnkbtn = sender as LinkButton;
    //getting particular row linkbutton
    GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
    //getting userid of particular row
    int Id = Convert.ToInt32(GV_LatLongApproval.DataKeys[gvrow.RowIndex].Value.ToString());
    DropDownList DDL = (DropDownList)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("drp_Closeby");
    Label Project = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Project");
    Label NewLat = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Userlat");
    Label NewLong = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Userlong");
    Label OldLat = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Sitelat");
    Label OldLong = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Sitelong");
    Label Username = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Username");
    Label Siteid = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Siteid");
    Label Sitename = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Sitename");
    Label OTime = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Requestedtime");
    Label Distance = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Distance");
    Label Circle = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Circle");
    Label MCompany = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_MCompany");
    Label SCompany = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_SCompany");
    Label Mobile = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Mobile");
    Label Zone = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Zone");

    if (DDL.SelectedValue.ToString() != "0")
    {
        string CloseBy = DDL.SelectedItem.Text;
        DA = new FindDataAccess();
        DataTable SiteDT = new DataTable();
        SiteDT = DA.SELECT_ID_SITEID(Siteid.Text);
        DA = new FindDataAccess();
        DA.select_update_lat_long_su(float.Parse(NewLat.Text), float.Parse(NewLong.Text), Convert.ToInt32(SiteDT.Rows[0]["ID"]), 1, Username.Text);
        DA = new FindDataAccess();
        DataTable DC = new DataTable();
        DC = DA.CLOSE_TT_22042016(Id, CloseBy, "Approve");
        if (DC.Rows.Count > 0)
        {
            if (Convert.ToInt32(DC.Rows[0][0].ToString()) == 1)
            {
                Send_Email_To_User("Approve", Project.Text, Username.Text, Siteid.Text, Sitename.Text, OTime.Text, DateTime.Now.ToString(), OldLat.Text, OldLong.Text, NewLat.Text, NewLong.Text, Distance.Text, Circle.Text, Mobile.Text, MCompany.Text, SCompany.Text, Zone.Text);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + Siteid.Text + " Request already processed.')", true);
            }
        }
        Fill_GV_LatLongApproval();
    }
    else
    {

    }
}

protected void lnbtn_Reject_Click(object sender, EventArgs e)
{
    LinkButton lnkbtn = sender as LinkButton;
    //getting particular row linkbutton
    GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
    //getting userid of particular row
    int Id = Convert.ToInt32(GV_LatLongApproval.DataKeys[gvrow.RowIndex].Value.ToString());
    DropDownList DDL = (DropDownList)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("drp_Closeby");
    Label Project = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Project");
    Label NewLat = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Userlat");
    Label NewLong = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Userlong");
    Label OldLat = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Sitelat");
    Label OldLong = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Sitelong");
    Label Username = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Username");
    Label Siteid = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Siteid");
    Label Sitename = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Sitename");
    Label OTime = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Requestedtime");
    Label Distance = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Distance");
    Label Circle = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Circle");
    Label MCompany = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_MCompany");
    Label SCompany = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_SCompany");
    Label Mobile = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Mobile");
    Label Zone = (Label)GV_LatLongApproval.Rows[gvrow.RowIndex].FindControl("lbl_Zone");

    if (DDL.SelectedValue.ToString() != "0")
    {
        string CloseBy = DDL.SelectedItem.Text;
        DA = new FindDataAccess();
        DataTable DC = new DataTable();
        DC = DA.CLOSE_TT_22042016(Id, CloseBy, "Reject");
        if (DC.Rows.Count > 0)
        {
            if (Convert.ToInt32(DC.Rows[0][0].ToString()) == 1)
            {
                // Send_Email_To_User("Approve", Username.Text, Siteid.Text, Sitename.Text, OTime.Text, DateTime.Now.ToString(), OldLat.Text, OldLong.Text, NewLat.Text, NewLong.Text, Distance.Text, Circle.Text, Mobile.Text, MCompany.Text, SCompany.Text);
                Send_Email_To_User("Reject", Project.Text, Username.Text, Siteid.Text, Sitename.Text, OTime.Text, DateTime.Now.ToString(), OldLat.Text, OldLong.Text, NewLat.Text, NewLong.Text, Distance.Text, Circle.Text, Mobile.Text, MCompany.Text, SCompany.Text, Zone.Text);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + Siteid.Text + " Request already processed.')", true);
            }
        }
        Fill_GV_LatLongApproval();
    }
    else
    {

    }
}

protected void Send_Email_To_User(string Action_Status, string ProjectName, string Username, string SiteId, string SiteName, string OTime, string CTime, string OLat, string OLong, string NLat, string NLong, string Distance, string Circle, string Mobile, string MCompnay, string SCompany, string Zone)
{
    try
    {
        mydataaccess2 da2 = new mydataaccess2();
        string to_email = "";
        to_email = da2.get_email_id_user(Username);

        if (to_email != "" && to_email != null)
        {
            // Vodafone SMTP Credentials
            string Body = Email_Body(Action_Status, ProjectName, Username, SiteId, SiteName, OTime, CTime, OLat, OLong, NLat, NLong, Distance, Circle, Mobile, to_email, MCompnay, SCompany, Zone);

            MailMessage message = new MailMessage("citappsupport@vodafone.com", to_email);
            if (Action_Status.ToLower() == "approve")
            {
                message.Subject = "Your Lat-Long Update Request Approved by Helpdesk For Site : " + SiteId;
            }
            else
            {
                message.Subject = "Your Lat-Long Update Request Rejected by Helpdesk For Site : " + SiteId;
            }
            message.Body = Body;
            message.CC.Add("la.helpdesk@gmail.com");
            message.IsBodyHtml = true;

            #region "VODAFONE SERVER CREDENTIALS"

            SmtpClient emailClient = new SmtpClient("10.87.138.252", 254);
            emailClient.Credentials =
                       new NetworkCredential("china@mobile.com", "51561615");

            emailClient.EnableSsl = false;

            #endregion

            #region "CREDENTIALS"

            //SmtpClient emailClient = new SmtpClient("china@mobile.com", 254);
            //emailClient.Credentials = new NetworkCredential("china@mobile.com", "51561615");
            //emailClient.EnableSsl = true;

            #endregion

            emailClient.Send(message);
        }
    }
    catch (Exception ex)
    {

    }
}

public string Email_Body(string Action_Status, string ProjectName, string Username, string SiteId, string SiteName, string OTime, string CTime, string OLat, string OLong, string NLat, string NLong, string Distance, string Circle, string Mobile, string Email, string MCompnay, string SCompany, String Zone)
{
    string Body = "";

    Body = "Dear " + Username + "<br><br>";

    if (Action_Status.ToLower() == "approve")
    {
        Body += "Your Lat / Long Request has been approved. Please refresh Your site selection page and select zone name as per below.<br><br>";

        Body += "";
        Body += "";
        Body += "";
        Body += "";
        Body += "";
        Body += "";
        Body += "";
        Body += "<table border="1"><tbody><tr style="background-color: red; color: white"><th>ProjectName</th><th>Site Id</th> <th>Site Name</th> <th>Zone</th> <th>Requested time by user</th> <th>Approve Time By Support Team</th> <th>Old lat of site</th> <th>Old long of site</th> <th>New lat of site</th> <th>New long of site</th> <th>Distance updated in mtr</th></tr><tr><td>" + ProjectName + "</td><td>" + SiteId + "</td> <td>" + SiteName + "</td> <td>" + Zone + "</td> <td>" + OTime + "</td> <td>" + CTime + "</td> <td>" + OLat + "</td> <td>" + OLong + "</td> <td>" + NLat + "</td> <td>" + NLong + "</td> <td>" + Distance + "</td></tr></tbody></table><br>";
    }
    else
    {
        Body += "Your Lat / Long Request has been Rejected due to Distance from site is more than 2km.<br><br>";
        Body += "If you want to Update lat-long as per your location ,then please take approval of your circle admin on this mail and send mail post approval to CIAT Helpdesk on ciat.ptw@gmail.com.<br>";
        Body += "Do not send this mail without any approval of your circle admin, Lat-long will not update by CIAT Help desk until Approval Given.<br><br>";

        Body += "";
        Body += "";
        Body += "";
        Body += "";
        Body += "";
        Body += "";
        Body += "";
        Body += "<table border="1"><tbody><tr style="background-color: red; color: white"><th>ProjectName</th><th>Site Id</th> <th>Site Name</th><th>Zone</th> <th>Requested time by user</th> <th>Rejected Time By Support Team</th> <th>Current lat of site</th> <th>Current long of site</th> <th>User lat</th> <th>User long</th> <th>Requested distance to update as per user location in mtr</th></tr><tr><td>" + ProjectName + "</td><td>" + SiteId + "</td> <td>" + SiteName + "</td> <td>" + Zone + "</td> <td>" + OTime + "</td> <td>" + CTime + "</td> <td>" + OLat + "</td> <td>" + OLong + "</td> <td>" + NLat + "</td> <td>" + NLong + "</td> <td>" + Distance + "</td></tr></tbody></table><br>";
    }

    Body += "";
    Body += "";
    Body += "";
    Body += "";
    Body += "";
    Body += "";
    Body += "";
    Body += "<table border="1"><tbody><tr style="background-color: red; color: white"><th>Requested by username</th> <th>Circle</th> <th>Mobile number of user</th> <th>EmailId of user</th> <th>Main company</th> <th>Sub Company</th></tr><tr><td>" + Username + "</td> <td>" + Circle + "</td> <td>" + Mobile + "</td> <td>" + Email + "</td> <td>" + MCompnay + "</td> <td>" + SCompany + "</td></tr></tbody></table><br>";

    Body += "Please Note :- Do not Reply on this mail if you have any query then ,please contact as below.<br><br>";
    Body += "Contact Us :-<br>";
    Body += "Helpdesk Number :- 079 40009543 , 8141587709 , 9978791606, 9727716004<br>";
    Body += "Email :- helpdesk@help.com<br>";

    return Body;
}


Что я уже пробовал:

я искал в интернете, но не могу получить надлежащую информацию, чтобы сделать это...

Karthik_Mahalingam

насчет избыточного веса?

3 Ответов

Рейтинг:
20

Karthik_Mahalingam

Цитата:
как отправить запрос с чьей-либо почты и из любого браузера, чтобы сразу выполнить событие click кнопок

На PageLoad событие веб-страницы. вызов события нажатия кнопки, непосредственно в котором вы хотите inovke.


Рейтинг:
13

Patrice T

Не твой вопрос, но .....

SmtpClient emailClient = new SmtpClient("10.87.138.24", 25);
emailClient.Credentials = new NetworkCredential("Chetan.Patel12@vodafone.com", "Sep@2016@P");

Совет: никогда не размещайте реальные учетные данные на публичном форуме.
Измените пароль как можно быстрее.


Member 12954126

Спасибо за предложение...

Рейтинг:
0

jimmson

Тело электронной почты-это HTML-not ASP.NET. Просто создайте HTML тело и добавьте normal <a href="..."> ссылки на ваши изображения, которые ведут на ваш сайт.


Member 12954126

я знаю, что это html, но как отправить запрос с чьей-либо почты и из любого браузера для прямого выполнения события click кнопок в visual studio, о котором я говорил выше?