Включение изображений в электронную почту Outlook
я пытаюсь использовать документ Microsoft Word в качестве основного элемента электронной почты Microsoft Outlook. До сих пор я смог включить текст из Word .docx в текст письма с кодом:
if (File.Exists(fileName.ToString()))
{
DateTime today = DateTime.Now;
object readOnly = false;
object isVisible = false;
//Set Word to invisible
wordApp.Visible = false;
//Open the word document
aDoc = wordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
try
{
//Activate Document
aDoc.Activate();
//Find Place Holders and replace them with values
this.FindAndReplace(wordApp, "", NameAddressed);
this.FindAndReplace(wordApp, "", SessionInfo);
this.FindAndReplace(wordApp, "", GuestNumber);
this.FindAndReplace(wordApp, "", Balance);
//Postal
this.FindAndReplace(wordApp, "", FullName);
this.FindAndReplace(wordApp, "", Address1);
if (Address2 != " " && Address2 != "" && Address2 != " ")
this.FindAndReplace(wordApp, "", Address1 + "\n\r" + Address2);
else
this.FindAndReplace(wordApp, "", Address1);
this.FindAndReplace(wordApp, "", City);
this.FindAndReplace(wordApp, "", State);
this.FindAndReplace(wordApp, "", Zip);
}
catch (Exception ex)
{
aDoc.Close(ref missing, ref missing, ref missing);
ClientScript.RegisterStartupScript(this.GetType(), "error", "javascript:;alert('" + ex.Message + "')");
return false;
}
aDoc.SaveAs(ref saveAs);
//Save the file as the correct file name
if (DataType.Text == "Email")
{
Outlook.Application oApp = new Outlook.Application();
// Create a new mail item.
Outlook.MailItem eMail = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
Word.Range r = aDoc.Content;
r.Select();
string s = r.Text;
eMail.Subject = "Confirmation Email";
eMail.To = "[email protected]";
eMail.Body = s;
((Outlook._MailItem)eMail).Send();
//Close the document - you have to do this
aDoc.Close(ref missing, ref missing, ref missing);
}
litError.Text = "File Created. ";
return true;
}
else
{
litError.Visible = true;
litError.Text = "File Does Not Exist";
return false;
}
Но этот код не будет включать изображения, которые также есть в документе Word в электронном письме. Есть ли способ, которым .docx также может отправлять свои изображения в Outlook и сохранять свой первоначальный формат? заранее спасибо