/// <summary> /// Initalizes email data. /// </summary> /// <param name="bulkEmail">Email instance.</param> /// <param name="messageInfo">Data nexessary for email sending.</param> private EmailMessage InitEmailMessage(IMessageInfo messageInfo) { var instantMessageInfo = messageInfo as InstantMessageInfo; BulkEmail bulkEmail = instantMessageInfo.BulkEmail; var messageImages = new List <image>(); var message = new EmailMessage { subject = bulkEmail.TemplateSubject, from_email = bulkEmail.SenderEmail, from_name = bulkEmail.SenderName, html = bulkEmail.TemplateBody, track_clicks = true, track_opens = true, images = messageImages, inline_css = true, important = true }; var macrosHelper = new MarketingMacrosHelper(_userConnection); string templateCode = GetTemplate(bulkEmail, messageInfo, messageImages, macrosHelper); var bulkEmailId = bulkEmail.GetTypedColumnValue <Guid>("Id"); PrepareRecipient(messageInfo, macrosHelper, message, bulkEmailId); message.html = templateCode; if (_isMetadataInitialized) { message.AddMetadata(BulkEmailMetadataValue, messageInfo.MessageId.ToString("N")); } if (macrosHelper.GlobalMergeVars.Any()) { message.InitGlobalVariable(); message.global_merge_vars.AddRange(macrosHelper.GlobalMergeVars); } return(message); }