简体   繁体   English

从自定义Outlook表单生成新电子邮件

[英]Generate new email from a custom outlook form

I have built a form that stores certain contact data on it. 我建立了一个在上面存储某些联系数据的表格。 I want to include a couple of buttons/functions to keep the user in the form as much as possible versus switching between Outlook components (calendar, mail, etc.). 我想包括几个按钮/功能,以使用户尽可能保持表单的状态,而不是在Outlook组件(日历,邮件等)之间进行切换。

In this case the user can swap email addresses from separate ListBoxes and when they hit the button it will use the emails within one of them. 在这种情况下,用户可以交换来自单独列表框的电子邮件地址,并且当他们单击按钮时,它将使用其中一个中的电子邮件。 Using VBS because I'm dealing with custom Outlook forms. 使用VBS是因为我正在处理自定义Outlook表单。

Sub GenerateButton_Click()
     'Generates Email with all of the CCs

     'Variables
     Set FormPage = Item.GetInspector.ModifiedFormPages("Commands")
     Set DoSend = FormPage.Controls("DoSendListBox")
     mailList = ""

     'Generate Email List
     For x = 0 to (DoSend.ListCount - 1)
         mailList = mailList & DoSend.List(x) & ";"
     Next

     'Compose Email
     Set msg = Application.CreateItem(olMailItem)
     msg.Subject = "Hello World!"
     msg.To = mailList
End Sub  

What Happens 怎么了
- it compiles -编译
- nothing happens on click -点击没有任何反应

Research 研究
- online forums usually in VBA -通常在VBA中的在线论坛
- relevant articles use outside connection rather than from within outlook -相关文章使用外部连接而不是从内部使用

SOLVED 解决了
Note: Click on the "script" option and select the object item. 注意:单击“脚本”选项,然后选择对象项。 From the new window you can navigate through the classes and from this I was able to find MailItem . 在新窗口中,您可以浏览这些类,由此我可以找到MailItem You can see all of the methods/properties on the right hand pane. 您可以在右侧窗格中看到所有方法/属性。

It Turns out the correct syntax was: 原来正确的语法是:

Set msg = Application.CreateItem(MailItem)
msg.Display

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM