4

我有一个场景,用户可以从网格中进行选择(在本地文件夹上上传文件),当用户按“发送”时,应用程序应该打开 Outlook“新邮件”窗口,其中选择文件作为附件(用户选择从网格)。

任何帮助将不胜感激。

4

3 回答 3

13
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))

使用 next 包括新的换行符:

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

将打开带有新邮件撰写对话框的默认电子邮件客户端。

如果 Outlook 设置为默认客户端,它将被打开。


无论如何,永远不要明确打开非默认客户端(电子邮件、浏览器等)——这会破坏客户的意愿并让他们讨厌你。

于 2010-12-27T10:01:53.063 回答
7

如果您特别想要一条 Outlook 消息,并且想要更多关于发送内容的选项(正文、附件、密件抄送等):

Dim Outl As Object
Outl = CreateObject("Outlook.Application")
If Outl IsNot Nothing Then
    Dim omsg As Object
    omsg = Outl.CreateItem(0) '=Outlook.OlItemType.olMailItem'
    'set message properties here...'
    omsg.Display(True) 'will display message to user
End If
于 2010-12-27T10:07:34.593 回答
6
Dim Outl As Object
Outl = CreateObject("Outlook.Application")
If Outl IsNot Nothing Then
    Dim omsg As Object
    omsg = Outl.CreateItem(0)
    omsg.To = "yusuf@hotmail.com"
    omsg.bcc = "yusuf@gmail.com"
    omsg.subject = "Hello"
    omsg.body = "godmorning"
    omsg.Attachments.Add("c:\HP\opcserver.txt")
    'set message properties here...'
    omsg.Display(True) 'will display message to user
于 2014-02-27T12:07:19.113 回答