How to launch email client through asp.net(c#) & managing cc and bcc mails.


Purpose:  to open client email from javascript side which accepts single email in to and more than one emails incc and agency email in bcc.

JavaScript :

function OpenEmailClient() {

var strEmail = $(‘#<%= hdnEmail.ClientID%>’).val();

var arrEmail = strEmail.split(“;”);

// alert(strEmail);

var toEmail = ”;

var bccEmail = ”;

var ccEmail = $(‘#<%= hdnAgencyEmail.ClientID%>’).val();

if(arrEmail.length>2)

{

bccEmail = strEmail;

}

else if(arrEmail.length==2)

{

toEmail = strEmail;

}

var strHref = ‘mailto:’ + toEmail + ‘?cc=’ + ccEmail + ‘&bcc=’ + bccEmail;

//debugger

window.open(strHref);

return false;

}

Taking hidden fields:   hidden fields name should be name as unique name of grid columns or cell.

<asp:hiddenfield id=”hdnEmail” runat=”server” />

<asp:hiddenfield id=”hdnAgencyEmail” runat=”server” />

Description: 

‘hdnEmail.ClientID’ and ‘hdnAgencyEmail’ is hidden field which is using for storing selected email value from grid or text box from server side.

window.open() function is required for opening new window with client email browser

Leave a comment

Your email address will not be published. Required fields are marked *