function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
David GunnDavid Gunn 

Link sent in email from Apex is changed in received email

I have Apex code that sends an email that contains a link to a Survey Monkey survey, similar to this stripped-down snippet:
 
public static void sendLink(String oppId, String emailaddr) { 
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); 
    String body; mail.setToAddresses(new string[] {emailaddr}); 
    mail.setSenderDisplayName('noreply@companyname.com'); 

    mail.setSubject('My subject'); body = 'This is a link: https://www.domain.net/asdf&z=' + oppId;
    mail.setPlainTextBody(body); 
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail } ); 
}
The email sends fine but the link received by the recipient is drastically different.

If the receipient is an email adress here at work the link is something like this: https://urldefense.proofpoint.com/v2/url?u=https-3A__ ... GC5BJ...D0063B...=...wICA&z=...nzTkWOdJlub_y7...&r=...bOKUVzc...

If it is sent to my personal hotmail address the URL is likewise changed and starts with this:
https://nam04.safelinks.protection.outlook.com/?url=https%3A...

I suspect that both target email systems have safeguards in place that "scrub" links that are found in emails. Is there something I can do in Apex that will allow the links to arrive to the recipient in tact?

Thank you.