如果outlook 2010关闭,EXe无效 [英] EXe is not working if outlook 2010 is closed
本文介绍了如果outlook 2010关闭,EXe无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了用于向outlook发送电子邮件参数
的exe(如toTo,主题和附件文件的路径),它对outlook 2013工作正常但是那么当我将它用于outlook 2010时,如果outlook 2010是开放的那么它很好,但当outlook 2010关闭时,那时我的exe工作不起作用。我也在下面提到我的代码
所以,请检查,如果可能的话给我解决方案。
Hi,
I create exe for sending the email parameter
to outlook(likeTo,Subject and path of the attachement file ),its working fine for outlook 2013 but when i use it for outlook 2010 then ,if outlook 2010 is open then it woking fine but when outlook 2010 is closed then at that time my exe is not working. I also mention my code in below
so, please check and if possible then give me the solution.
static void Main(string[] args)
{
string to, sub, path;
to = sub = path = string.Empty;
Console.WriteLine("Enter to");
to = Console.ReadLine();
Console.WriteLine("Enter sub");
sub = Console.ReadLine();
Console.WriteLine("Enter path");
path = Console.ReadLine();
Console.WriteLine("Please Wait....");
CreateMessageWithAttachment(path, to, sub);
}
public static void CreateMessageWithAttachment(string path, string to, string subject)
{
try
{
Outlook.Application oApp = new Outlook.Application();
Outlook.MailItem email = (Outlook.MailItem)(oApp.CreateItem(Outlook.OlItemType.olMailItem));
#region set email recipients
{
email.Recipients.Add(to);
}
#endregion
//email subject
email.Subject = subject;
#region set email Text
{
// email.Body = body;
}
#endregion
#region email attachment
{
if (File.Exists(path))
{
// int iPosition = (int)email.Body.Length + 1;
int iAttachType = (int)Outlook.OlAttachmentType.olByValue;
Outlook.Attachment oAttach = email.Attachments.Add(path, iAttachType);
}
}
#endregion
email.Display();
}
catch (Exception e)
{
}
}
谢谢
hasan
Thanks
hasan
推荐答案
您不需要Outlook发送电子邮件,请参阅此处: http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx [ ^ ]
You don't need Outlook to send emails, see here : http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx[^]
这篇关于如果outlook 2010关闭,EXe无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文