Outlook:通过VBA-Makro打开表单,并使用ThisOutlookSession的设置发送邮件 [英] Outlook: Open Form via VBA-Makro and send Mail with settings of ThisOutlookSession

查看:787
本文介绍了Outlook:通过VBA-Makro打开表单,并使用ThisOutlookSession的设置发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像标题一样,我想通过Outlook的Ribbon中的按钮打开表单。此表单包含所选邮件的MailBody和一些DropDown字段。
当你点击'发送'时,应该弹出一个MsgBox,它在ThisOutlookSession中定义,但它不起作用。
当我使用选择表格手动打开表格时,它可以工作。
这是一个错误,还是有任何解决方法?
预先感谢您,请询问是否有任何问题。






我使用VBA。
在ThisOutlookSession中的Project1下,我得到了下面的代码:
$ b $ Private $ Application_ItemSend(ByVal Item As Object,Cancel As Boolean)
MsgBox(Hallo)
End Sub



表单存储/发布在私有表单库中,带有以下代码的模块:

  Set cstmControls = otlMAPIFolder.Items.Add(IPM.Note.Formular3)

但是,当我点击功能区的发送按钮时,MsgBox不会出现。



模块的完整代码,它调用表单:

  Option Explicit 
公共otlAppl作为Outlook.Application
公共otlMAPINameSpace作为命名空间
公共otlMAPIFolder作为MAPIFolder
公共otlMailItem作为的MailItem
公共cstmControls作为的MailItem
公共cstmUprop作为UserProperties

Sub FormSend()
Set otlAppl = CreateObject(Outlook.Application)
Set otlMAPINameSpace = ot lAppl.GetNamespace( MAPI)
将otlMAPIFolder = otlMAPINameSpace.GetDefaultFolder(olFolderInbox)
将otlMailItem = ActiveExplorer.Selection.Item(1)
将cstmControls = otlMAPIFolder.Items.Add( IPM.Note.Formular3\" )
组cstmUprop = cstmControls.UserProperties

身体
尺寸strBody作为字符串
strBody = otlMailItem.Body

收件人
尺寸strTo作为字符串
strTo = otlMailItem.SenderEmailAddress

strBody = strBody
将cstmControls
。为了= strTo
.Body = strBody
.Display True
End With


End Sub


解决方案

它看起来像ItemSend事件不在Outlook中触发。



跑步?什么是信托中心的宏设置和程序化访问设置?



您从哪里获得Application类?



使用Application_Startup()事件来实例化您的事件处理应用程序对象。你可以阅读更多有关的的 ItemSend未针对Outlook 2010发起攻击 - 安全性不高论坛主题。


like in the headline I want to open a Form via a Button in the Ribbon of Outlook. This Form contains the MailBody of the selected Mail and some DropDown Fields. When you click on 'Send' there should pop up a MsgBox wich is defined in ThisOutlookSession, but it does not work. When I open the Form manually with the 'Choose Form', it works. Is this a bug, or is there any workaround? Thank you in advance and please ask if anything is not clear.


I use VBA. Under Project1 in ThisOutlookSession I have got following Code:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) MsgBox ("Hallo") End Sub

The Form is stored/published under private forms library and is called from a module with the following code:

Set cstmControls = otlMAPIFolder.Items.Add("IPM.Note.Formular3")

But when I click the Send Button of the Ribbon the MsgBox does not appear.

The full Code of the Module, which calls the Form:

Option Explicit 
Public otlAppl As Outlook.Application
Public otlMAPINameSpace As NameSpace
Public otlMAPIFolder As MAPIFolder
Public otlMailItem As MailItem
Public cstmControls As MailItem
Public cstmUprop As UserProperties

Sub FormSend()
Set otlAppl = CreateObject("Outlook.Application")
Set otlMAPINameSpace = otlAppl.GetNamespace("MAPI")
Set otlMAPIFolder = otlMAPINameSpace.GetDefaultFolder(olFolderInbox)
Set otlMailItem = ActiveExplorer.Selection.Item(1)
Set cstmControls = otlMAPIFolder.Items.Add("IPM.Note.Formular3")
Set cstmUprop = cstmControls.UserProperties

'Body
    Dim strBody As String
    strBody = otlMailItem.Body

'Recipient
Dim strTo As String
    strTo = otlMailItem.SenderEmailAddress

strBody = strBody
With cstmControls
        .To = strTo
        .Body = strBody
        .Display True
    End With


End Sub

解决方案

It looks like the ItemSend event is not fired in Outlook.

Are macros enabled for running? What are the settings for Macro Settings and Programmatic Access in the Trust Center?

Where did you get the Application class?

Use the Application_Startup() event to instantiate your event handling Application object. You can read more about that on the ItemSend not firing for outlook 2010 - Security is Low forum thread.

这篇关于Outlook:通过VBA-Makro打开表单,并使用ThisOutlookSession的设置发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆