如何从VB.NET中打开Outlook "新邮件信息 "窗口?

问题描述 投票:4回答:4

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

任何帮助将被感激。

.net vb.net email email-client
4个回答
6
投票

如果你想特别想要一个Outlook邮件,并且你想有更多的选项来发送(正文,附件,BCC等)。

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

12
投票
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))

使用下一步包括新的换行符。

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

将打开默认的电子邮件客户端与新的信息组成对话框。

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


总之,千万不要明确地打开非默认客户端(电子邮件、浏览器等)--那会破坏客户端的意志,使其成为 你。


5
投票
Dim Outl As Object
Outl = CreateObject("Outlook.Application")
If Outl IsNot Nothing Then
    Dim omsg As Object
    omsg = Outl.CreateItem(0)
    omsg.To = "[email protected]"
    omsg.bcc = "[email protected]"
    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
© www.soinside.com 2019 - 2024. All rights reserved.