C #: What is the best way to send a support request by email?

I have a Windows Forms application in which I am adding a request support form and would like the user to be able to enter values ​​and click a button. Once the button is pressed, I can:

  • Open a new email message and fill in the message automatically. (Do not know how to do this)
  • Submit your request via the http form on my website. (I know how to do this).
  • Send an email directly from the application code. (I know how to do this).

What I want to know is the best method? I think that option 1 is the most transparent, and the user will see what is sent, but I'm not sure how to ensure it works regardless of which email client it uses.

I see that there are potential problems with option two, in particular, the firewall may stop serving. But option 2 would allow me to supply them with the ticket number on the right and there for their request.

Thanks for the help.

+3
source share
4 answers

For option 1, as suggested, use the mailto handler.

Format a string like this: string.Format("mailto:support@example.com?subject={0}&body={1}", subject, body). Do not forget UrlEncode object and body values.

Then use System.Diagnostics.Process.Start () with your string.

This will launch the registered mail handler (Outlook, Windows Live Mail, Thunderbird, etc.) on the system.

+2
source

1: , mailto , . , - . ( - gmail, SOL, )

+1

2) , HTTP- .

2) . , , - URL- /. SMTP -.

- ( ) - ( ).

0

(1) Outlook. ( , Outlook, )

        //using Microsoft.Office.Interop.Outlook;       
        private void OutlookMail(string Subject, string Body)
        {

        ApplicationClass app = new ApplicationClass();
        NameSpaceClass ns = (NameSpaceClass)app.GetNamespace("mapi");
        ns.Logon("", "", true, true);
        MailItem mi =
            (MailItem)app.CreateItem(OlItemType.olMailItem);
        mi.Subject = Subject;

        int EOFPos = Body.IndexOf(char.Parse("\0"));
        if (EOFPos != -1)
        {
            log.Error("EOF found in Mail body");
            ErrorDialog ed = new ErrorDialog(TietoEnator.Common.ErrorDialog.ErrorDialog.Style.OK, "Export Error", "File could not be exported correctly, please inform responsible person", "", "EOF char detected in the body of email message.");
            ed.ShowDialog();
        Body=Body.Replace("\0", "");
        }
        mi.HTMLBody = "<html><head><META content='text/html; charset=CP1257' http-equiv=Content-Type></head><body><table>"+Body+"</table></body></html>";

        mi.BodyFormat = OlBodyFormat.olFormatHTML;//.olFormatPlain; 
        mi.Display(0); // show it non - modally
        ns.Logoff();
    }

BTW for automatic support requests that I plan to use in my current Microsoft Exchange Logging Support Block project.

0
source

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


All Articles