【问题标题】:VBA Excel drag and drop email from outlookVBA Excel 从 Outlook 拖放电子邮件
【发布时间】:2017-12-14 12:34:16
【问题描述】:

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

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

将电子邮件从 Outlook 拖放到 Excel 按钮

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

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

我正在尝试执行导入阶段(从 Outlook 拖放),但没有找到执行此操作的方法...

感谢您的帮助

【问题讨论】:

  • 为什么不简单地使用 excel 的 vba 来收集所有电子邮件并根据需要保存它们,而不是拖放功能?

标签: vba excel outlook drag-and-drop


【解决方案1】:

您不能将电子邮件放在按钮上(好吧,您可以但是...) 而是创建一个编辑框 (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

【讨论】:

  • 和上拖放,哪个是最好的方式?
  • ...好吧,首先单击并按住该项目,然后将其拖动到所需位置并释放鼠标按钮。
猜你喜欢
  • 1970-01-01
  • 2018-03-25
  • 1970-01-01
  • 2016-02-05
  • 2010-09-06
  • 2020-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多