VB 6.0 - 打开默认电子邮件客户端并填充一些条目

时间:2015-04-24 12:47:41

标签: vb.net vb6

我最近在VB 2010创建了一个应用程序,为了使其成为.Net Framework中的个人,我开始在VB 6.0重新构建应用程序。

我有一个按钮,可以打开默认电子邮件客户端,并使用文本框中的文本填充正文。

VB 2010中,它的工作原理如下:

Process.Start("mailto:test@email.com?subject= &body=" & System.Uri.EscapeDataString(Textbox1.Text))

你能帮我找到一种方法来完成上述VB 6.0中的工作吗?

2 个答案:

答案 0 :(得分:1)

为此,请使用ShellExecute API

Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _
   As String, ByVal lpFile As String, ByVal lpParameters _
   As String, ByVal lpDirectory As String, ByVal nShowCmd _
   As Long) As Long

Private Sub myButton_Click()
    ShellExecute Me.hWnd, "open", "mailto:test@email.com?subject= &body=" & Textbox1.Text, _
                 vbNullString, vbNullString, 1
End Sub

如果您想要转义TextBox1.Text,请检查this question

答案 1 :(得分:0)

VB6具体

  

外壳功能

     

运行可执行程序并返回表示程序任务ID的Variant(Double),否则返回零。

     

语法

Shell(pathname[,windowstyle])
  

Shell函数语法具有以下命名参数:

     

部分描述   pathname必需;变体(字符串)。要执行的程序的名称以及任何所需的参数或命令行开关;可能包括目录或文件夹和驱动器。   windowstyle可选。 Variant(Integer)对应于要运行程序的窗口的样式。如果省略windowstyle,程序将以焦点最小化启动。

     

windowstyle命名参数具有以下值:

Constant Value Description 
vbHide 0 Window is hidden and focus is passed to the hidden window.  
vbNormalFocus 1 Window has focus and is restored to its original size and position. 
vbMinimizedFocus 2 Window is displayed as an icon with focus. 
vbMaximizedFocus 3 Window is maximized with focus. 
vbNormalNoFocus 4 Window is restored to its most recent size and position. The currently active window remains active. 
vbMinimizedNoFocus 6 Window is displayed as an icon. The currently active window remains active. 
  

说明

     

如果Shell函数成功执行了命名文件,它将返回已启动程序的任务ID。任务ID是标识正在运行的程序的唯一编号。如果Shell函数无法启动指定的程序,则会发生错误。

     

注意默认情况下,Shell函数以异步方式运行其他程序。这意味着在Shell函数执行后的语句之前,使用Shell启动的程序可能无法完成执行。