hyperlink email address in textbox and send it via Outlook

后端 未结 2 591
遇见更好的自我
遇见更好的自我 2021-01-24 16:56

I am working on a wpf app, and I have a Customer Information section where I can record my customer information. In this section, I use a textbox recording customer\'s email add

2条回答
  •  暖寄归人
    2021-01-24 17:57

    you can try code XAML

    Refer a friend
    

    code behind

     private void tbReferAFriend_MouseDown(object sender, MouseButtonEventArgs e)
                {
                    try
                    {
    
                       LaunchEmailClientByShellExecute();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace);
                    }
                }
    
        [DllImport("shell32.dll")]
                public static extern IntPtr ShellExecute(IntPtr hwnd, string lpOperation,
                    string lpFile, string lpParameters, string lpDirectory, int nShowCmd);
    
                private void launchEmailClientByShellExecute()
                {
                    ShellExecute(IntPtr.Zero, "open", "mailto:username?subject=Read%20This&body=message%20contents", "", "", 4/* sw_shownoactivate */);
                }
    

    from : https://social.msdn.microsoft.com/Forums/vstudio/en-US/dcbaaced-97b3-4276-bf95-960e77cb6c03/how-to-launch-default-mail-client-in-wpf-applications?forum=wpf

提交回复
热议问题