Click here to Skip to main content
16,004,576 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have a mailto button that copy the actual link of my page.I want that when my users click on the button, it copies them a hyperlink with the link of my page


What I have tried:

public void GenerateShareMenu(string copyLink, string emailLink, string msTeamsLink = "")
{
    this.ClientSideEvents.ItemClick = "MenuNoPostBackForGridActionMenu";
    var moreMenu = this.Items.Add();
    moreMenu.Name = "RootMenu";
    moreMenu.TextTemplate = new ITAMMenuTemplate("share", string.Empty, false);

    var copyLinkMenu = moreMenu.Items.Add();
    copyLinkMenu.Text = PSStringUtils.GetString("CommonCopyLink");
    copyLinkMenu.Name = "RootCopyMenu";
    copyLinkMenu.TextTemplate = new ITAMMenuTemplate("link", copyLinkMenu.Text, false);
    copyLinkMenu.NavigateUrl = copyLink;

    //if (!string.IsNullOrEmpty(msTeamsLink))
    //{
    //    var msTeamsMenu = moreMenu.Items.Add();
    //    msTeamsMenu.Text = PSStringUtils.GetString("CommonTeams");
    //    msTeamsMenu.Name = "RootMSTeamsMenu";
    //    msTeamsMenu.TextTemplate = new ITAMMenuTemplate("groups", msTeamsMenu.Text, false);
    //    msTeamsMenu.NavigateUrl = string.Format(CultureInfo.InvariantCulture, @"javascript:$('#{0}').click();", msTeamsLink);
    //}

    if (!string.IsNullOrEmpty(emailLink))
    {
        var sendMailLinkMenu = moreMenu.Items.Add();
        sendMailLinkMenu.Text = PSStringUtils.GetString("Common_SendEmail");
        sendMailLinkMenu.Name = "RootSendMailMenu";
        sendMailLinkMenu.TextTemplate = new ITAMMenuTemplate("forward_to_inbox", sendMailLinkMenu.Text, false);
        string htmlLink = $"<a href='{HttpUtility.HtmlEncode(emailLink)}'>Oui</a>";
        string emailBody = HttpUtility.UrlEncode(htmlLink);
        sendMailLinkMenu.NavigateUrl = $"mailto:?body={emailBody}";
    }
}
Posted

1 solution

The first thing that springs to mind is "why?"

Advice point number 1 in any "beware the scammers" session is always "never follow links in emails" - and for very good reason!

So your feature is going to either be ignored, or flagged as "scam activity" by email protection systems which will route your email to quarantine. Is that what you want to happen?
 
Share this answer
 
Comments
theo Jul2024 4-Jul-24 7:11am    
I have to use this for my customers because I have a big website where my customers send product links to each other, so it's not a fraudulent activity in any way.
I have to do this because my customers have complained that the page links are too long.
The objective is not to send an email to hack people who click on the link, it's simply to make the user experience even better.
OriginalGriff 4-Jul-24 8:59am    
So use a link shrinker: send a short link like "mydomain.com/ABCDEFGH" and use a "page not found" handler to convert that (via a DB) to an actual page then redirect to that.
Dave Kreskowiak 4-Jul-24 10:41am    
Another reason to not use mailto is because those URL's are limited to about 2K, depending on the browser processing that link. This includes the recipients, CCs, BCCs, Subject line, and the entire body of the email, so if your entire email can fit inside about 2000 characters, you're good. But if it has even the slightest possibility of exceeding that limit, forget using mailto.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900