Create an email to be downloaded by the client and sent from your Outlook account.

One of the requirements for the application I'm working on is to provide users with a debug report to our support team for fatal errors (similar to Windows error reports).

I was told that emails should come from the customerโ€™s email account to prevent spam from the support service, as well as a lot of repeated calls.

To achieve this, I try to compose an email message on the server with a complete message in the body for reference and report the error as an attachment, and then add it to the response so that the user can download, open and send it.

I tried without success to use the component for interacting with Outlook, which is a controversial point, because I have found over the past 6 hours at Google that creating more than several instances of the application is very resource-intensive.

+4
source share
3 answers

In one of our applications, the user clicks the generate button and creates and opens email in Outlook. All they need to do is click the submit button. Features below.

public static void generateEmail(string emailTo, string ccTo, string subject, string body, bool bcc) { Outlook.Application objOutlook = new Outlook.Application(); Outlook.MailItem mailItem = (Outlook.MailItem)(objOutlook.CreateItem(OlItemType.olMailItem)); /* Sets the recipient e-mails to be either sent by 'To:' or 'BCC:' * depending on the boolean called 'bcc' passed. */ if (!(bcc)) { mailItem.To = emailTo; } else { mailItem.BCC = emailTo; } mailItem.CC = ccTo; mailItem.Subject = subject; mailItem.Body = body; mailItem.BodyFormat = OlBodyFormat.olFormatPlain; mailItem.Display(mailItem); } 

As you can see, it displays an e-mail message in clear text at the moment, because it must be friendly to the blackberry. You can easily change the HTML or richtext format if you want some formatting options. To use HTML mailItem.HTMLBody

Hope this helps.

EDIT:

I should note that this is used in a C # application and that it refers to Microsoft.Office.Core and using Outlook in the email class the function is in.

+1
source

If you want the user to send the mail client side, I donโ€™t see how System.Net.Mail will help you.

You have two options:

  • mailto: support@domain.com ?subject=Error&body=Error message here...

  • ask the user to download the email in some format, open it in your client and send it

Option 1 is likely to be broken down into complex bodies. In option 2, you need to find the format supported by all email clients (which your users use).

With option 1, you can save the email data locally on your server using some error identifier and simply send an email with the error identifier in the subject:

mailto: support@domain.com ?subject=Error 987771 encountered

+4
source

The simple answer is that what you are trying to achieve is unrealistically achievable on all platforms and email clients. When asked to do the incredible, itโ€™s wise to come up with an alternative and assume that.

Assuming that the crash report is only accessible from the error page, you already have a barrier to spam - if spammers cannot throw an exception.

I have always dealt with this by recording errors and text in the database and integrating them with the ticketing system. There may also be mailto: as Bruce suggests with subject = ID & body = text to allow the user to send something via email.

I donโ€™t think that an .eml file will help either - because they will need to forward it, and most users are probably confused.

A.eml is a plain text message, including headers according to RFC-5322.

+2
source

Source: https://habr.com/ru/post/1315565/


All Articles