[英]VBA Excel drag and drop email from outlook
我在excel中开发了一个表单,该表单正在将电子邮件发送到邮箱。 这部分工作正常。
现在,我正在寻找开发“后台” excel工作簿,该工作簿将允许:
将电子邮件从Outlook拖放到Excel按钮
将此电子邮件保存到文件夹
阅读此电子邮件,并将所有部分(发件人的电子邮件,主题,正文等)保存在Excel电子表格中。
我正在尝试执行导入阶段(从Outlook拖放),但是没有找到实现此目的的方法...
谢谢你的帮助
您不能将电子邮件放在按钮上(但是,您可以...),而是创建一个编辑框(Outlookbox)并将其绑定到事件处理程序。 以下是一些入门代码:
Private Sub Outlookbox_Change()
Dim olApp As Object 'Outlook.Application
Dim olExp As Object 'Outlook.Explorer
Dim olSel As Object 'Outlook.Selection
Dim i As Integer
Dim theSender as String
Dim theDate as String
Dim theRecipient as String
Dim theSubject as String
Dim theMessage as String
Set olApp = GetObject("", "Outlook.Application")
Set olExp = olApp.ActiveExplorer
Set olSel = olExp.Selection
For i = 1 To olSel.Count ' If multiple emails dropped
With olSel.Item(i) ' For each email
theSender = .Sender
theDate = .ReceivedTime
theRecipient = .To
theSubject = .Subject
theMessage = .Body
End With
Next i
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.