我希望从我的程序中生成Outlook消息,我可以在程序内部构建并发送消息,也可以构建并保存。但是我想先构建邮件,然后显示给用户手动选择AD列表中的收件人。下面的代码混合了这里和其他教程网站的样本,但没有找到只构建然后“显示”电子邮件而不在程序内部保存草稿或发送的方法。
另外,我正在寻找一种在电子邮件中创建UNC链接的方法,例如:编写到用户文件夹路径的路径\\unc\path\%USERNAME%或类似内容。
另外,我正在寻找一种在电子邮件中创建UNC链接的方法,例如:编写到用户文件夹路径的路径\\unc\path\%USERNAME%或类似内容。
private void sendEmailOutlook(string savedLocation, string packageName)
{
try
{
Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
oMsg.HTMLBody = "Attached is the required setup files for your <i><b>soemthing</i></b> deployment package.";
oMsg.HTMLBody += "\nPlease save this file to your network user folder located.<br /><br/>\\\\UNC\\data\\users\\%USER%\\";
oMsg.HTMLBody += "\nOnce saved please boot your Virtual machine, locate and execute the file at <br /> <br />\\\\UNC\\users\\%USER%\\";
int pos = (int)oMsg.Body.Length +1;
int attachType = (int)Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue;
Microsoft.Office.Interop.Outlook.Attachment oAttach = oMsg.Attachments.Add(savedLocation, attachType, pos, packageName);
oMsg.Subject = "something deployment package instructions";
oMsg.Save();
}
catch(Exception ex)
{
Console.WriteLine("Email Failed", ex.Message);
}
<a></a>
)? - Herdo