简体   繁体   中英

What is the best way to display an exchange mail message on an ASP.net web page?

I have a list of actions happend on an item listed on an ASP.net website. These actions are logged in a simple sql table linked to the item. ie:

[2013-11-04 18:00]: Problem solved
[2013-11-04 18:00]: Called User
[2013-11-04 14:00]: Mail Received

For this, I will have to query the support mailbox for new mail messages. When a new message is received, a 'mail received' action is created. The 'mail recieved' entry should be clickable so the support user can see the contents of this message.

Question:

Using Exchange Webservices Managed API 2.0 I can find this message and his body but the message body can have inline images and other layouts.

Options:

  1. Show the message on the web page try to render the mail message the best way I can.
    Something like this but that can be used in a web page?

  2. Use Outlook to display this email message.

  3. 1&2 combined.. show a preview text-only message and click to see the whole message using outlook.

Since the support user will have Outlook 2010 or higher installed on his machine, the 3th option seems a logical choice but

@{
    HttpContext.Current.Response.AddHeader("Content-disposition", "inline;filename=message.msg");
    HttpContext.Current.Response.ContentType = "application/vnd.ms-outlook";
}
@(new HtmlString(ViewBag.Body))

Obviously doesn't work.. a .msg file seems binary.

But even when this works I will have these problems:

  1. Every time you open a message you will have to click 'Open' to view this message.

  2. When this support user answers this message using his outlook, this message will be sent 'from' his account. There would be no trace of this sent message!

We are using an on-premise Exchange 2010 SP3 server that should be migrated to Exchange Online some time next year. Application is running on ASP.NET 4.5 using MVC 5.0 framework.

Tinker with the different body types and retrieval methods. Info here:

http://msdn.microsoft.com/en-us/library/ee217562(v=exchg.80).aspx

See if any of them return something that's relatively easy to display, whether that be parsing the HTML body or showing the RTF body in the browser. I haven't mucked with this much and don't have an Exchange server handy or I'd check myself. If Exchange doesn't chew up the HTML when the message is send, you may be able to parse out the src="cid:contentIdOfAttachment" and replace it with a proper link to the attachment for display in the browser, but Exchange can do funny things to HTML and CSS.

And for clarification, by "support user", do you mean a support employee (ie, tech support) or someone who is receiving support and checking on the status of their ticket? If the message is to be shown and/or replied to in Outlook, would this person be accessing a single support mailbox (perhaps a public folder) or would the message be forwarded/copied to the person's individual mailbox?

If I'm getting this right, you'll be copying it to an individual mailbox, and from there it's "outside" the system, so the reply goes straight to the end user and skips the central support mailbox. You might be able to circumvent this by altering the message before it is sent/downloaded by changing the "from" to the central support mailbox. When the support user responds, it goes back to the central support mailbox, where you can have a secondary sync action (or even the same one that's fetching incoming mail) process it, change the to/from to send to the intended recipient from the central support mailbox, and send it off by using UpdateItems and saving it to the Sent folder. It's not pretty, but it should be possible. That's just off the top of my head, though, so there could easily be a better solution. And I'm operating on a few assumptions about the system you're working in, so maybe I have things a bit wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM