调用Outlook电子邮件时,C#asp.net超时 [英] c# asp.net timeout when calling a outlook email

查看:136
本文介绍了调用Outlook电子邮件时,C#asp.net超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  

我的要求是,我需要开发一个web应用程序,(它是强制性的
  是一个Web应用程序)。结果
  这个应用程序将列出已经后市模板
  直接保存在一个特定的。结果,
  旁每个模板,有一个负载
  按钮,你可以说一个负载链接,如果你想
  当代理(客户端)
  单击它,后市应与该模板打开。


我试图打开从我的asp.net应用程序的前景。当我在我的按钮点击,我执行这个code

  Microsoft.Office.Interop.Outlook._MailItem oMailItem2 = oApp.CreateItemFromTemplate(templateFilePath);
oMailItem2.Display(真);

这是我工作的机器上,但是当我在服务器上部署它,我得到这个错误:

 请求超时。说明:执行当前Web请求的执行过程中发生未处理的异常。请查看有关错误的详细信息的堆栈跟踪以及它起源于code。异常详细信息:System.Web.HttpException:请求超时。源错误:当前Web请求的执行过程中生成了未处理的异常。有关异常的来源和位置信息可以使用异常堆栈跟踪下面确定。堆栈跟踪:
[HttpException(0x80004005的):请求超时。]版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.17929

这似乎是一个非常普遍的错误,可能是什么问题吗?我该如何诊断呢?

注意

在我的情况下,消息的主体必须是HTML,而不是文字。这就是为什么我不能够的mailto 像这样

 <一href=\"mailto:someone@example.com?subject=This%20is%20the%20subject&cc=someone_else@example.com&body=This%20is%20the%20body\">Send电子邮件< / A>


解决方案

所以,你必须在服务器上.msg文件,并且希望对其进行编辑,并将其传送给用户。

1)修改模板

<一个href=\"https://www.google.it/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=c%23+edit+.msg+file\" rel=\"nofollow\">https://www.google.it/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=c%23+edit+.msg+file

有许多第三方工具,可以帮助编辑.msg文件结果
2。它发送给用户

 使用(的FileStream FS = File.OpenRead(路径))
{
INT长度=(INT)fs.Length;
字节[]缓冲区;使用(BinaryReader BR =新BinaryReader(FS))
{
缓冲液= br.ReadBytes(长);
}Response.Clear();
将Response.Buffer =真;
Response.AddHeader(内容处置的String.Format(附件;文件名= {0},Pa​​th.GetFileName(路径)));
Response.ContentType =应用程序/+ Path.GetExtension(路径).Substring(1);
Response.BinaryWrite(缓冲液);
到Response.End()
}

My requirement is that i need to develop a web app , (it is mandatory to be a web app).
This app lists the outlook templates that has been saved in a specific directly.
Beside each template, there is a load button, you can say a load link if you want When the agent (client) clicks it, the outlook should open with that template.

I am trying to open the outlook from my asp.net application. when i click on my button, i execute this code

Microsoft.Office.Interop.Outlook._MailItem oMailItem2 = oApp.CreateItemFromTemplate(templateFilePath);
oMailItem2.Display(true);

It is working on my machine, but when i deploy it on the server, i got this error:

Request timed out.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: Request timed out.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[HttpException (0x80004005): Request timed out.]

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929

It seems a very general error, what could be the problem please? how can I diagnosis it?

Note

The body of the message in my case must be a html, not text. that is why i am not able to mailto like this

<a href="mailto:someone@example.com?subject=This%20is%20the%20subject&cc=someone_else@example.com&body=This%20is%20the%20body">Send email</a>

解决方案

So you have a .msg file on the server, and you want to edit it and transmit it to users.

1) edit your template

https://www.google.it/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=c%23+edit+.msg+file

there are many 3rd party tools that can help to edit a .msg files
2. Send it to the user

using (FileStream fs = File.OpenRead(path)) 
{ 
int length = (int)fs.Length; 
byte[] buffer; 

using (BinaryReader br = new BinaryReader(fs)) 
{ 
buffer = br.ReadBytes(length); 
} 

Response.Clear(); 
Response.Buffer = true; 
Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", Path.GetFileName(path))); 
Response.ContentType = "application/" + Path.GetExtension(path).Substring(1); 
Response.BinaryWrite(buffer); 
Response.End() 
}

这篇关于调用Outlook电子邮件时,C#asp.net超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆