Created
July 9, 2018 08:31
-
-
Save lmedikonda/ec1315517bef421c49dd4912cb52e547 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.IO; | |
using System.Net.Mail; | |
using System.Reflection; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using Amazon.SimpleEmail.Model; | |
using Amazon; | |
using System.Configuration; | |
using System.Threading.Tasks; | |
using System.Data; | |
using System.Threading; | |
using System.Diagnostics; | |
using System.Xml; | |
using Print2Flash3; | |
using off=Microsoft.Office.Interop.Word; | |
using System.Net; | |
/// <summary> | |
/// Summary description for Blogic | |
/// </summary> | |
public class Blogic | |
{ | |
public Blogic() | |
{ | |
// | |
// TODO: Add constructor logic here | |
// | |
} | |
public static MemoryStream ConvertMailMessageToMemoryStream(MailMessage message) | |
{ | |
Assembly assembly = typeof(SmtpClient).Assembly; | |
Type mailWriterType = assembly.GetType("System.Net.Mail.MailWriter"); | |
MemoryStream fileStream = new MemoryStream(); | |
ConstructorInfo mailWriterContructor = mailWriterType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(Stream) }, null); | |
object mailWriter = mailWriterContructor.Invoke(new object[] { fileStream }); | |
MethodInfo sendMethod = typeof(MailMessage).GetMethod("Send", BindingFlags.Instance | BindingFlags.NonPublic); | |
sendMethod.Invoke(message, BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { mailWriter, true,true }, null); | |
MethodInfo closeMethod = mailWriter.GetType().GetMethod("Close", BindingFlags.Instance | BindingFlags.NonPublic); | |
closeMethod.Invoke(mailWriter, BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { }, null); | |
return fileStream; | |
} | |
public static MailResponse SendRawEmail(String from, List<string> to,List<string> ccAddresses,List<string> bccAddresses, String Subject, string body=null,List<string> attachments=null, String html = null,Salesforce.Contact[] contacts=null, String replyTo = null, String returnPath = null) | |
{ | |
MailResponse mresponse = new MailResponse(); | |
try | |
{ | |
MailMessage mailMessage = new MailMessage(); | |
mailMessage.From = new MailAddress(from); | |
mailMessage.Body = body; | |
mailMessage.Subject = Subject; | |
mailMessage.SubjectEncoding = Encoding.UTF8; | |
foreach (string attachment in attachments) | |
mailMessage.Attachments.Add(new System.Net.Mail.Attachment(attachment)); | |
if (body != null) | |
{ | |
AlternateView plainView = AlternateView.CreateAlternateViewFromString(body, Encoding.UTF8, "text/plain"); | |
mailMessage.AlternateViews.Add(plainView); | |
} | |
if (html != null) | |
{ | |
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(html, Encoding.UTF8, "text/html"); | |
mailMessage.AlternateViews.Add(htmlView); | |
} | |
RawMessage rawMessage = new RawMessage(); | |
Amazon.SimpleEmail.IAmazonSimpleEmailService ses; | |
if(ConfigurationManager.AppSettings["AWSRegion"]=="USWest2") | |
ses = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(ConfigurationManager.AppSettings["AWSAccessKey"], ConfigurationManager.AppSettings["AWSSecretKey"],Amazon.RegionEndpoint.USWest2); | |
else | |
ses = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(ConfigurationManager.AppSettings["AWSAccessKey"], ConfigurationManager.AppSettings["AWSSecretKey"],Amazon.RegionEndpoint.USEast1); | |
foreach (String toAddress in to) | |
{ | |
mailMessage.To.Add(new MailAddress(toAddress)); | |
using (MemoryStream memoryStream = ConvertMailMessageToMemoryStream(mailMessage)) | |
{ | |
rawMessage.Data = memoryStream; | |
} | |
SendRawEmailRequest request = new SendRawEmailRequest(); | |
request.RawMessage = rawMessage; | |
request.Source = from; | |
request.Destinations.Add(toAddress); | |
CallAmazonSES(request, ses); | |
request.Destinations.Clear(); | |
mailMessage.To.Clear(); | |
} | |
foreach (String ccAddress in ccAddresses) | |
{ | |
mailMessage.CC.Add(new MailAddress(ccAddress)); | |
using (MemoryStream memoryStream = ConvertMailMessageToMemoryStream(mailMessage)) | |
{ | |
rawMessage.Data = memoryStream; | |
} | |
SendRawEmailRequest request = new SendRawEmailRequest(); | |
request.RawMessage = rawMessage; | |
request.Source = from; | |
request.Destinations.Add(ccAddress); | |
CallAmazonSES(request, ses); | |
request.Destinations.Clear(); | |
mailMessage.CC.Clear(); | |
} | |
List<List<string>> bccAddressesList = Split(bccAddresses); | |
foreach (List<String> bcclist in bccAddressesList) | |
{ | |
using (MemoryStream memoryStream = ConvertMailMessageToMemoryStream(mailMessage)) | |
{ | |
rawMessage.Data = memoryStream; | |
} | |
SendRawEmailRequest request = new SendRawEmailRequest(); | |
request.RawMessage = rawMessage; | |
request.Source = from; | |
request.Destinations.AddRange(bcclist); | |
CallAmazonSES(request, ses); | |
} | |
mresponse.Response = "Mail sent succesfully"; | |
} | |
catch (Exception ex) | |
{ | |
mresponse.Response = "Mail failed due to " + ex.Message; | |
} | |
return mresponse; | |
} | |
public static List<List<string>> Split(List<string> source) | |
{ | |
return source | |
.Select((x, i) => new { Index = i, Value = x }) | |
.GroupBy(x => x.Index / 40) | |
.Select(x => x.Select(v => v.Value).ToList()) | |
.ToList(); | |
} | |
public static void CallAmazonSES(SendRawEmailRequest request, Amazon.SimpleEmail.IAmazonSimpleEmailService ses) | |
{ | |
SendRawEmailResponse response = ses.SendRawEmail(request); | |
SendRawEmailResult result = response.SendRawEmailResult; | |
} | |
public static MailResponse SendRawCustomEmail(String from, List<string> ccAddresses, List<string> bccAddresses, String Subject, RequestArguments args,string mailField,bool showOptout=false, string body = null, List<string> attachments = null, String html = null, List<Salesforce.Contact> contacts = null, String replyTo = null, String returnPath = null,string contactId=null,string callListId=null) | |
{ | |
string workMail; | |
MailResponse mresponse = new MailResponse(); | |
try | |
{ | |
//11-04-2016 | |
string fromDomain = from.Split('@').Last(); | |
BAL bal = new BAL(); | |
DataSet ds = bal.GetJSonDestinationEmail(fromDomain); | |
List<int> SesNotidList = new List<int>(); | |
List<string> suppressedContacts = new List<string>(); | |
Dictionary<int, string> DestEmailsdict = new Dictionary<int, string>(); | |
for(int i=0;i<ds.Tables[0].Rows.Count;i++) | |
{ | |
DestEmailsdict.Add(Convert.ToInt32(ds.Tables[0].Rows[i][0]), Convert.ToString(ds.Tables[0].Rows[i][1])); | |
} | |
Blogic logic = new Blogic(); | |
MailMessage mailMessage = new MailMessage(); | |
mailMessage.From = new MailAddress(from); | |
mailMessage.SubjectEncoding = Encoding.UTF8; | |
foreach (string attachment in attachments) | |
mailMessage.Attachments.Add(new System.Net.Mail.Attachment(attachment)); | |
RawMessage rawMessage = new RawMessage(); | |
Amazon.SimpleEmail.IAmazonSimpleEmailService ses; | |
if (ConfigurationManager.AppSettings["AWSRegion"] == "USWest2") | |
ses = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(ConfigurationManager.AppSettings["AWSAccessKey"], ConfigurationManager.AppSettings["AWSSecretKey"], Amazon.RegionEndpoint.USWest2); | |
else | |
ses = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(ConfigurationManager.AppSettings["AWSAccessKey"], ConfigurationManager.AppSettings["AWSSecretKey"], Amazon.RegionEndpoint.USEast1); | |
foreach (Salesforce.Contact con in contacts) | |
{ | |
mailMessage.Subject = Subject; | |
mailMessage.To.Clear(); | |
if (mailField != null) | |
{ | |
workMail = Convert.ToString(con.GetType().GetProperty(mailField).GetValue(con, null)); | |
if (workMail == null && workMail == "") | |
{ | |
if (!DestEmailsdict.ContainsValue(con.Email)) | |
{ | |
mailMessage.To.Add(new MailAddress(con.Email)); | |
mailMessage = logic.ToMessagebody(mailMessage, body, html, con.FirstName, con.LastName, showOptout,con.Id); | |
CallAmazonSES(mailMessage, rawMessage, from, con.Email, ses); | |
} | |
else | |
{ | |
SesNotidList.Add(DestEmailsdict.FirstOrDefault(x => x.Value == con.Email).Key); | |
suppressedContacts.Add(con.Id); | |
} | |
} | |
else | |
{ | |
if (!DestEmailsdict.ContainsValue(workMail)) | |
{ | |
mailMessage.To.Add(new MailAddress(workMail)); | |
mailMessage = logic.ToMessagebody(mailMessage, body, html, con.FirstName, con.LastName, showOptout,con.Id); | |
CallAmazonSES(mailMessage, rawMessage, from, workMail, ses); | |
} | |
else | |
{ | |
SesNotidList.Add(DestEmailsdict.FirstOrDefault(x => x.Value == workMail).Key); | |
suppressedContacts.Add(con.Id); | |
} | |
} | |
} | |
else | |
{ | |
if (!DestEmailsdict.ContainsValue(con.Email)) | |
{ | |
mailMessage.To.Add(new MailAddress(con.Email)); | |
mailMessage = logic.ToMessagebody(mailMessage, body, html, con.FirstName, con.LastName, showOptout,con.Id); | |
CallAmazonSES(mailMessage, rawMessage, from, con.Email, ses); | |
} | |
else | |
{ | |
SesNotidList.Add(DestEmailsdict.FirstOrDefault(x => x.Value == con.Email).Key); | |
suppressedContacts.Add(con.Id); | |
} | |
} | |
} | |
mailMessage.Subject = Subject; | |
mailMessage.To.Clear(); | |
mailMessage = logic.CCMessagebody(mailMessage, body, html,showOptout); | |
foreach (String ccAddress in ccAddresses) | |
{ | |
if (!DestEmailsdict.ContainsValue(ccAddress)) | |
{ | |
mailMessage.CC.Clear(); | |
mailMessage.CC.Add(new MailAddress(ccAddress)); | |
CallAmazonSES(mailMessage, rawMessage, from, ccAddress, ses); | |
} | |
else | |
{ | |
SesNotidList.Add(DestEmailsdict.FirstOrDefault(x => x.Value == ccAddress).Key); | |
} | |
} | |
List<List<string>> bccAddressesList = Split(bccAddresses); | |
foreach (List<String> bcclist in bccAddressesList) | |
{ | |
using (MemoryStream memoryStream = ConvertMailMessageToMemoryStream(mailMessage)) | |
{ | |
rawMessage.Data = memoryStream; | |
} | |
SendRawEmailRequest request = new SendRawEmailRequest(); | |
request.RawMessage = rawMessage; | |
request.Source = from; | |
request.Destinations.AddRange(bcclist); | |
CallAmazonSES(request, ses); | |
} | |
int res = bal.UpdateJsonAttempts(SesNotidList); | |
new Thread(() => | |
{ | |
createTask(args, Subject, suppressedContacts, callListId, plainBody: body, htmlBody: html); | |
}).Start(); | |
mresponse.Response = "Mail sent succesfully"; | |
} | |
catch (Exception ex) | |
{ | |
mresponse.Response = "Mail failed due to " + ex.Message; | |
} | |
return mresponse; | |
} | |
//create task | |
public static void createTask(RequestArguments args,string subject,List<String> contactIds,string callListId,string plainBody=null,string htmlBody=null) | |
{ | |
try | |
{ | |
SFPartner.SforceService sfservice = new SFPartner.SforceService(); | |
sfservice.SessionHeaderValue = new SFPartner.SessionHeader(); | |
sfservice.SessionHeaderValue.sessionId = args.SessionId; | |
sfservice.Url = args.ServerUrl.Replace("/c/", "/u/"); | |
SFPartner.sObject[] tasks = new SFPartner.sObject[contactIds.Count]; | |
for (int i = 0; i < contactIds.Count; i++) | |
{ | |
SFPartner.sObject newTask = new SFPartner.sObject(); | |
newTask.type = "Task"; | |
System.Xml.XmlElement[] taskElement = new System.Xml.XmlElement[6]; | |
System.Xml.XmlDocument taskDocument = new System.Xml.XmlDocument(); | |
taskElement[0] = taskDocument.CreateElement("Subject"); | |
taskElement[0].InnerText = "Email Suppressed :" + subject; | |
taskElement[1] = taskDocument.CreateElement("Description"); | |
if (plainBody != null) | |
{ | |
taskElement[1].InnerText = plainBody; | |
} | |
else | |
{ | |
taskElement[1].InnerText = htmlBody; | |
} | |
taskElement[2] = taskDocument.CreateElement("WhoId"); | |
taskElement[2].InnerText = contactIds[i]; | |
taskElement[3] = taskDocument.CreateElement("Status"); | |
taskElement[3].InnerText = "Completed"; | |
taskElement[4] = taskDocument.CreateElement("WhatId"); | |
taskElement[4].InnerText = callListId; | |
taskElement[5] = taskDocument.CreateElement("ActivityDate"); | |
taskElement[5].InnerText = DateTime.Today.ToString("yyyy-MM-dd hh:mm:ss"); | |
newTask.Any = taskElement; | |
//SFPartner.sObject[] tasks = new SFPartner.sObject[1]; | |
tasks[i] = newTask; | |
} | |
SFPartner.SaveResult[] saveResult = sfservice.create(tasks); | |
} | |
catch { } | |
} | |
//create task | |
public static void CallAmazonSES(MailMessage mailMessage, RawMessage rawMessage, string from, string to, Amazon.SimpleEmail.IAmazonSimpleEmailService ses) | |
{ | |
using (MemoryStream memoryStream = ConvertMailMessageToMemoryStream(mailMessage)) | |
{ | |
rawMessage.Data = memoryStream; | |
} | |
SendRawEmailRequest request = new SendRawEmailRequest(); | |
request.RawMessage = rawMessage; | |
request.Source = from; | |
request.Destinations.Add(to); | |
SendRawEmailResponse response = ses.SendRawEmail(request); | |
request.Destinations.Clear(); | |
} | |
public MailMessage CCMessagebody(MailMessage mailMessage, string body, string html, bool showOptout = false) | |
{ | |
mailMessage.AlternateViews.Clear(); | |
mailMessage.Subject = mailMessage.Subject.Replace("{!FirstName}", ""); | |
mailMessage.Subject = mailMessage.Subject.Replace("{!LastName}", ""); | |
mailMessage.SubjectEncoding = Encoding.UTF8; | |
if (body != null) | |
{ | |
body = body.Replace("{!FirstName}", ""); | |
body = body.Replace("{!LastName}", ""); | |
AlternateView plainView = AlternateView.CreateAlternateViewFromString(body, Encoding.UTF8, "text/plain"); | |
mailMessage.AlternateViews.Add(plainView); | |
} | |
if (html != null) | |
{ | |
html = html.Replace("{!FirstName}", ""); | |
html = html.Replace("{!LastName}", ""); | |
// Add unsubscribe url | |
/* if (showOptout) | |
{ | |
string url = "https://parser.talentrover.com/TalentRover/Optout.aspx"; | |
var uriBuilder = new UriBuilder(url); | |
var query = HttpUtility.ParseQueryString(uriBuilder.Query); | |
query["s"] = Convert.ToString(mailMessage.From); | |
query["d"] = Convert.ToString(mailMessage.To); | |
uriBuilder.Query = query.ToString(); | |
url = uriBuilder.ToString(); | |
html = html + "<br><br>Please click the below link to Unsubscribe if you do not want to receive Emails<br>"; | |
html = html + "<a href='" + url + "' target='_blank'>Unsubscribe</a>"; | |
}*/ | |
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(html, Encoding.UTF8, "text/html"); | |
mailMessage.AlternateViews.Add(htmlView); | |
} | |
return mailMessage; | |
} | |
public MailMessage ToMessagebody(MailMessage mailMessage,string body,string html,string firstName,string lastName, bool showOptout = false, string Id ="") | |
{ | |
mailMessage.AlternateViews.Clear(); | |
mailMessage.Subject = mailMessage.Subject.Replace("{!FirstName}", firstName); | |
mailMessage.Subject = mailMessage.Subject.Replace("{!LastName}", lastName); | |
if (body != null) | |
{ | |
body = body.Replace("{!FirstName}", firstName); | |
body = body.Replace("{!LastName}", lastName); | |
body =body.Replace("{!Contact.Id}", Id); | |
AlternateView plainView = AlternateView.CreateAlternateViewFromString(body, Encoding.UTF8, "text/plain"); | |
mailMessage.AlternateViews.Add(plainView); | |
} | |
if (html != null) | |
{ | |
html = html.Replace("{!FirstName}", firstName); | |
html = html.Replace("{!LastName}", lastName); | |
html = html.Replace("{!Contact.Id}", Id); | |
// Add unsubscribe url | |
if(showOptout) | |
{ | |
string url = "https://parser.talentrover.com/TalentRover/Optout.aspx"; | |
var uriBuilder = new UriBuilder(url); | |
var query = HttpUtility.ParseQueryString(uriBuilder.Query); | |
query["s"] =Convert.ToString(mailMessage.From); | |
query["d"] =Convert.ToString(mailMessage.To); | |
uriBuilder.Query = query.ToString(); | |
url = uriBuilder.ToString(); | |
html = html + "<br/><br/><a href='" + url+"' target='_blank'>Unsubscribe</a>"; | |
} | |
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(html, Encoding.UTF8, "text/html"); | |
mailMessage.AlternateViews.Add(htmlView); | |
} | |
return mailMessage; | |
} | |
//Kill winword process | |
public static void killWinWordProcess() | |
{ | |
try | |
{ | |
Process[] processlist = Process.GetProcessesByName("WINWORD"); | |
foreach (Process theprocess in processlist) | |
{ | |
//if (theprocess.StartTime.TimeOfDay < DateTime.Now.AddMinutes(-5.0).TimeOfDay && theprocess.ProcessName == "WINWORD") | |
if (theprocess.StartTime.TimeOfDay < DateTime.Now.AddMinutes(-5.0).TimeOfDay) | |
{ | |
theprocess.Kill(); | |
} | |
} | |
} | |
catch { } | |
} | |
public static void HealthCheck(String force) | |
{ | |
GenerateXMLRequest req = new GenerateXMLRequest(); | |
try | |
{ | |
//Removed by Lakshminarayan to fix the issue W-014335 | |
/* byte[] data = File.ReadAllBytes(@"C:\inetpub\wwwroot\TalentRover\Test\sample.docx"); | |
Print2FlashService p2f = new Print2FlashService(new AliasId("123-docx-er")); | |
SWFResponse res = p2f.Convert(data, runChecks: false); | |
if (res.error != null) | |
{ | |
req.flashNotes = res.error; | |
req.isFlashSuccess = false; | |
System.Diagnostics.Process.Start(@"C:\inetpub\wwwroot\TalentRover\Test\cleanup.bat"); | |
} | |
else | |
{ */ | |
req.flashNotes = "Success"; | |
req.isFlashSuccess = true; | |
// } | |
} | |
catch (Exception ex) | |
{ | |
req.flashNotes =ex.Message; | |
req.isFlashSuccess = false; | |
} | |
XmlDocument xmlDoc = new XmlDocument(); | |
xmlDoc.Load(@"C:\inetpub\wwwroot\TalentRover\Test\HealthCheck.xml"); | |
XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes("/Services/FormatResume"); | |
DateTime dt = Convert.ToDateTime(nodeList[0].SelectSingleNode("LastCheck").InnerText); | |
if (force == "1") | |
{ | |
//modified by Lakshminarayana on 03-05-2018 for W-014630 | |
/* MailMergeTestResponse mmres = Blogic.MailMergeTest(); | |
if (mmres.MailMergeError != null) | |
{ | |
req.formatNotes = mmres.MailMergeError; | |
req.isFormatSuccess = false; | |
} | |
else | |
{*/ | |
req.formatNotes = "Success"; | |
req.isFormatSuccess = true; | |
// } | |
} | |
else | |
{ | |
req.isFormatSuccess = Convert.ToBoolean(nodeList[0].SelectSingleNode("Success").InnerText); | |
req.formatNotes = nodeList[0].SelectSingleNode("Success").InnerText; | |
} | |
GenerateXML(req); | |
} | |
public static void GenerateXML(GenerateXMLRequest req) | |
{ | |
XmlTextWriter writer = new XmlTextWriter(@"C:\inetpub\wwwroot\TalentRover\Test\HealthCheck.xml", System.Text.Encoding.UTF8); | |
writer.WriteStartDocument(true); | |
writer.Formatting = Formatting.Indented; | |
writer.Indentation = 2; | |
writer.WriteStartElement("Services"); | |
createNode("FlashGeneration",req.isFlashSuccess, req.flashNotes, writer); | |
createNode("FormatResume", req.isFormatSuccess, req.formatNotes, writer); | |
writer.WriteEndElement(); | |
writer.WriteEndDocument(); | |
writer.Close(); | |
} | |
private static void createNode(string node,bool success, string error, XmlTextWriter writer) | |
{ | |
writer.WriteStartElement(node); | |
writer.WriteStartElement("ServerUrl"); | |
writer.WriteString(Convert.ToString(HttpContext.Current.Application["CaptchaUrl"])); | |
writer.WriteEndElement(); | |
writer.WriteStartElement("Success"); | |
writer.WriteString(Convert.ToString(success)); | |
writer.WriteEndElement(); | |
writer.WriteStartElement("StatusNotes"); | |
writer.WriteString(error); | |
writer.WriteEndElement(); | |
writer.WriteStartElement("LastCheck"); | |
writer.WriteString(Convert.ToString(System.DateTime.Now.ToString("o"))); | |
writer.WriteEndElement(); | |
writer.WriteEndElement(); | |
} | |
//mailMergeTest method created by jameer on 27-09-2016 | |
public static MailMergeTestResponse MailMergeTest() | |
{ | |
MailMergeTestResponse response = new MailMergeTestResponse(); | |
string templatepath = @"C:\inetpub\wwwroot\TalentRover\Test\TestTemplate.docx"; | |
string InputResume = @"C:\inetpub\wwwroot\TalentRover\Test\sample.docx"; | |
Object oMissing = System.Reflection.Missing.Value; | |
MailMergeProcess mm = new MailMergeProcess(); | |
string outfile=null; | |
try | |
{ | |
Object oTemplatePath = @templatepath; | |
off.Application wordApp = new off.Application(); | |
off.Document wordDoc = new off.Document(); | |
wordDoc = wordApp.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing); | |
foreach (off.Field myMergeField in wordDoc.Fields) | |
{ | |
off.Range rngFieldCode = myMergeField.Code; | |
string fieldName = mm.GetFieldName(rngFieldCode.Text); | |
if (fieldName != null && fieldName != "body") | |
{ | |
myMergeField.Select(); | |
wordApp.Selection.TypeText("talentRover"); | |
} | |
else if (fieldName == "body") | |
{ | |
myMergeField.Select(); | |
wordApp.Selection.InsertFile(@InputResume); | |
} | |
else if (fieldName == null) | |
{ } | |
else | |
{ | |
myMergeField.Select(); | |
wordApp.Selection.TypeText(" "); | |
} | |
} | |
outfile = ConfigurationManager.AppSettings["OutboundResume"] + Guid.NewGuid() + ".doc"; | |
wordDoc.SaveAs(outfile); | |
wordApp.Documents.Open(outfile); | |
wordApp.Application.Quit(); | |
Thread.Sleep(1000); | |
byte[] docbytes = File.ReadAllBytes(@outfile); | |
response.FormatResume = Convert.ToBase64String(docbytes); | |
response.isSuccess = true; | |
return response; | |
} | |
catch (Exception e) | |
{ | |
response.MailMergeError = e.Message; | |
response.isSuccess = false; | |
return response; | |
} | |
} | |
// mailMergeTest method created by jameer on 27-09-2016 | |
} | |
public class GenerateXMLRequest | |
{ | |
public Boolean isFlashSuccess { get; set; } | |
public string flashNotes { get; set; } | |
public Boolean isFormatSuccess { get; set; } | |
public string formatNotes { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment