Outlook.Application app = new Outlook.Application(); Outlook.MailItem item = (Outlook.MailItem)app.CreateItemFromTemplate(@"C:\Users\orculloj\Desktop\Sample2\tEST.msg", Type.Missing); string body = item.HTMLBody; string imgSrc = @"~\images\logo.png"; string res = ""; string bdy = ""; string cid = ""; var contentID = "logo"; var inlineLogo = new Attachment(@"C:\Users\orculloj\Documents\Visual Studio 2013\Projects\WebApplication3\WebApplication3\images\logo.png"); inlineLogo.ContentId = contentID; inlineLogo.ContentDisposition.Inline = true; inlineLogo.ContentDisposition.DispositionType = DispositionTypeNames.Inline; Match srcMatch = Regex.Match(item.HTMLBody, @"src=[""](?<url>[^""]+)[""]", RegexOptions.IgnoreCase); if (srcMatch.Success) { int srcIndex = srcMatch.ToString().IndexOf(srcMatch.ToString()); if (srcIndex != -1) { Match cidMatch = Regex.Match(srcMatch.ToString(), @"[""](?<url>[^""]+)[""]", RegexOptions.IgnoreCase); if (cidMatch.Success) { int cidIndex = cidMatch.ToString().IndexOf(cidMatch.ToString()); if (cidIndex != -1) { string cd = @"""cid:" + contentID +"\""; res = item.HTMLBody.Replace(cidMatch.ToString(), cd); //bdy = string.Format(res, inlineLogo.ContentId); } } //cid = res; } } MailMessage m = new MailMessage(); // Address and send the message m.From = new MailAddress("DEV_MNL@altisource.com", "DEV_MNL"); m.To.Add(new MailAddress("JohnEmmanuel.Orcullo@altisource.com", "Orcullo, John Emmanuel C")); m.Subject = "This is a test email"; m.IsBodyHtml = true; m.Body = res; SmtpClient client = new SmtpClient("Internal-Mail.ascorp.com"); client.Send(m);</url></url>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)