I'm populating an email template and I'm having some issues with the button onclick event.
What I am trying to achieve is when clicking on the button it should open a URL in a new window rather than a new tab.
Currently when the email gets sent it is losing the onclick event functionality. Any recommendations on how can I achieve this?
I have also tried creating the button in the html template rather than replacing the tags as code below, but still run into the same issue.
HTML Code:
<p>
Hi,
</p>
<p>
A [JobType], to start on [JobStartDate]
<br />
Click here to view the job: [JobUrl]
</p>
<p>
<b>Job Details:</b>
<br />
- Reference: [JobReferenceNumber]
<br />
- Checklist: [AnswerEvaluationName]
<br />
- Created by: [JobCreator]
<br />
</p>
<p>
Kind regards<br />
</p>
<p class="auto-style6">
Please do not reply to this system generated email
</p>
</body>
public void CreateEmailNotificationForNewJob()
{
// Populate the Email Template
string EmailRecipientTestingNotes = "";
string EmailSubject = "";
string EmailTemplate = EmailSender.LoadEmailTemplate("EmailNewJob.html");
string EmailTo = "";
string TestButton = ("<input type=\"button\" onclick=\"window.open('https://www.google.com/','mywin','width=500,height=500');\">");
EmailSubject = "Job/task ";
EmailTemplate = EmailTemplate.Replace("[JobReferenceNumber]", "Reference");
EmailTemplate = EmailTemplate.Replace("[AnswerEvaluationName]", "Daily Update");
EmailTemplate = EmailTemplate.Replace("[JobStartDate]", "Today");
EmailTemplate = EmailTemplate.Replace("[JobType]", "1");
EmailTemplate = EmailTemplate.Replace("[CompanySiteName]", "");
EmailTemplate = EmailTemplate.Replace("[SiteName]", "");
EmailTemplate = EmailTemplate.Replace("[JobUrl]", TestButton);
EmailTo = "test@test.co.za";
try
{
// Send email code
}
catch (Exception ex)
{
// Add handling
}
}