捕获时间邮件已发送 [英] Capture time mail was sent
问题描述
我是Outlook对象库的新手。我有一个Excel工作簿,其中包含电子邮件模板和附件的列表。我有一个插入按钮为每个列表项分开合并每个电子邮件(根据过程需要)。我已经写了代码来组合它们并显示一个电子邮件:
I am new to the Outlook Object Library. I have an Excel workbook that contains a list of email templates and attachments. I have an insert button for each list item to separately combine each email (required as per procedure). I have written the code to combine them and display an email:
Public Sub SendToThisPerson()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim r, c As Integer
Dim b As Object
Set b = ActiveSheet.Buttons(Application.Caller)
With b.TopLeftCell
r = .Row
c = .Column
End With
r = 14
c = 3
Dim filename As String, subject1 As String, path1, path2, wb As String
Dim wbk As Workbook
filename = ThisWorkbook.Worksheets(1).Cells(r, c + 4)
path1 = Application.ThisWorkbook.Path & ThisWorkbook.Worksheets(1).Range("F4")
path2 = Application.ThisWorkbook.Path & ThisWorkbook.Worksheets(1).Range("F6")
wb = ThisWorkbook.Worksheets(1).Cells(r, c + 7)
Dim outApp As Outlook.Application
Dim oMail As Outlook.MailItem
Set outApp = New Outlook.Application
Set oMail = outApp.CreateItemFromTemplate(path1 & filename)
oMail.Display
subject1 = oMail.subject
subject1 = Left(subject1, Len(subject1) - 10) & Format(ThisWorkbook.Worksheets(1).Range("D7"), "DD/MM/YYYY")
Set wbk = Workbooks.Open(filename:=path2 & wb)
wbk.Worksheets(1).Range("I4") = ThisWorkbook.Worksheets(1).Range("D7").Value
wbk.Close True
With oMail
.subject = subject1
.Attachments.Add (path2 & wb)
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
用户决定发送还是不发送。我想抓住如果发送
按钮被点击,添加发送到工作表的时间。
我尝试了应用程序事件,但可能我对于所有对此问题感兴趣的人,请查找解决方案的进展:
The user decides either to send or not to send. I would like to catch if the Send
button was clicked, add the time of the send to the worksheet.
I experimented with Application events but probably I have a wrong understanding of that.
推荐答案
href =https://stackoverflow.com/questions/43940570/excel-vba-manual-outlook-email-sender-class-module-issue> EXCEL VBA,手册Outlook电子邮件发件人,类模块问题
For all who are interested in this problem, find the progression on the solution: EXCEL VBA, Manual Outlook email sender, Class module Issue
这篇关于捕获时间邮件已发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!