In today's project, we need to do this: click a button to open the mail window.
According to the project requirements, you do not need to implement the mail function by yourself. You only need to call the system's mail function.
How can I enable Outlook Express to send emails?
I tried the following:
(1), use system. Diagnostics. process to open ie using the parameter mailto: dingo_zgl@msn.com, you can open,CodeAs follows:
System. Diagnostics. processstartinfo startinfo = New System. Diagnostics. processstartinfo ( " Iexplore.exe " , " Mailto: dingo_zgl@msn.com " );
System. Diagnostics. process. Start (startinfo );
But the problem is: This method opens the IE window.
Then I added the following sentence:
Startinfo. windowstyle = System. Diagnostics. processwindowstyle. hidden;
The IE window is hidden, but the iexplore process cannot be closed when the mail window is closed.
(2) The process of viewing the sending mail window is: msimn
You can directly use system. Diagnostics. process to open msimn.exe but find the Outlook Express interface. It does not seem feasible.
(3) later, we found that we can use the win api platform to call this function. Therefore, we should use the following methods to solve the problem:
Public Class Win32
{
[Dllimport ( " Shell32.dll " , Entrypoint = " Shellexecutea " )]
Public Static Extern Int ShellExecute (
Int Hwnd,
String lpoperation,
String lpfile,
String lpparameters,
String lpdirectory,
Int Nshowcmd
);
}
Use in button events:
Win32.shellexecute ( 0 , String. empty, " Mailto: dingo_zgl@msn.com " , String. Empty, String. empty, 1 );
This requirement has been fulfilled.
Do you know what other good methods do you have? I also started to develop. net. Please give me more advice!