VBA Excel从Outlook拖放电子邮件

我在excel中开发了一个表单,这个表单发送一封邮件到一个邮箱。 这部分工作正常。

现在我正在寻找开发一个“后台”Excel工作簿,这将允许:

拖放电子邮件从Outlook到excelbutton

将此电子邮件保存到一个文件夹

阅读此电子邮件,并将所有部分(发件人的电子邮件,主题,正文…)保存在Excel电子表格中。

我正在尝试进行导入阶段(拖放从outlook),但没有find办法做到这一点…

谢谢你的帮助

你不能在一个button上放一个电子邮件(当然,你可以…)而是创build一个编辑框(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 
Interesting Posts