[英]VBA Excel drag and drop email from outlook
I have developed a form in excel, which is sending an email to a mailbox. 我在excel中开发了一个表单,该表单正在将电子邮件发送到邮箱。 This part is working fine.
这部分工作正常。
Now i'm looking to develop an "back-office" excel workbook Which would allow to : 现在,我正在寻找开发“后台” excel工作簿,该工作簿将允许:
Drag and drop email from outlook to an excel button 将电子邮件从Outlook拖放到Excel按钮
Save this email to a folder 将此电子邮件保存到文件夹
Reading this email, and saving all parts (sender's email, subject, body, ...) in an excel spreadsheet. 阅读此电子邮件,并将所有部分(发件人的电子邮件,主题,正文等)保存在Excel电子表格中。
I'm trying to do the import phase (drag and drop from outlook) but didn't find the way to do this... 我正在尝试执行导入阶段(从Outlook拖放),但是没有找到实现此目的的方法...
Thanks for your help 谢谢你的帮助
You cannot drop an email on a button (well, you can but ...) Instead create an editbox (Outlookbox) and tie it to an event handler. 您不能将电子邮件放在按钮上(但是,您可以...),而是创建一个编辑框(Outlookbox)并将其绑定到事件处理程序。 Here's some code to get you started:
以下是一些入门代码:
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.