宏不显示打开的邮件

时间:2016-09-13 12:44:08

标签: vba outlook outlook-vba

以下是我发送电子邮件的宏,但它没有打开新电子邮件。

此宏位于Outlook规则中。

你有什么想法吗?

  Sub sendemail()

  Dim ns As NameSpace
 'Dim newMail As Outlook.MailItem

Set ns = GetNamespace("MAPI")
 Dim newMail As MailItem
Set newMail = Application.CreateItem()

With newMail
  .To = "aaa@bbb" <--adress to whitch I want to send an email
  .Subject = "test"
  .Display
 End With
Set newMail = Nothing

  End Sub

3 个答案:

答案 0 :(得分:0)

首先你需要加上outlook参考:

enter image description here

你去了:

然后:

Sub sendemail()

  Dim outlook As New outlook.Application
 Dim newMail As outlook.MailItem

    Set newMail = outlook.CreateItem(olMailItem)


    With newMail
      .To = "email@address.com" ' <--adress to whitch I want to send an email
      .Subject = "test from Steph"
      .Display
      .Send
     End With
    Set newMail = Nothing
    outlook.Quit
    Set outlook = Nothing

  End Sub

答案 1 :(得分:0)

参数必须为 MailItem MeetingItem ,才能使子规则在Outlook规则向导中可用。

试试这个。

Option Explicit
Sub SendEmail(NewMail As Outlook.MailItem)

    Set NewMail = Application.CreateItem(olMailItem)

    With NewMail
        .To = "aaa@bbb"  '<--adress to whitch I want to send an email
        .Subject = "test"
        .Display
    End With

    Set NewMail = Nothing
End Sub

答案 2 :(得分:-1)

您没有指定要创建的项目。见这里:

mvn help:describe -Dplugin=org.apache.maven.plugins:maven-war-plugin\
                  -Ddetail=true

来源:http://www.vbforums.com/showthread.php?536558-RESOLVED-Outlook-late-binding

此版本也使用后期绑定,因此您不需要任何其他参考。