[英]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.