How to open Outlook “New mail message” window from VB.NET

前端 未结 3 1532
逝去的感伤
逝去的感伤 2021-01-03 06:30

I\'ve a scenario in which user can make a selection from a grid (having uploaded files on local folder) and when user press \"send\", application should open Outlook \"New m

3条回答
  •  走了就别回头了
    2021-01-03 07:20

    Imports System.Diagnostics
    
    Process.Start(String.Format("mailto:{0}", address))
    
    ' set all possible parameters: '
    
    Process.Start(String.Format("mailto:{0}?subject={1}&cc={2}&bcc={3}&body={4}", address, subject, cc, bcc, body))
    
    ' also escape spaces: '
    
    Process.Start(String.Format("mailto:{0}?subject=\"{1}\"&cc={2}&bcc={3}&body=\"{4}\"", address, subject, cc, bcc, body))
    

    Use next to include new line breaks:

    body = body.Replace(Environment.NewLine ,"%0A")
    

    will open default email client with new message composition dialog.

    If Outlook is set as default client, it will be opened.


    Anyway, never open explicitly non-default client (email, browser, etc) - that breaks clients' will and makes them hate you.

提交回复
热议问题