기본 VBA 코드를 사용하여 매일 내 스프레드 시트 복사본을 이메일로 보냅니다. 이메일 제목은 항상 같습니다.동일한 Outlook 대화에서 VBA를 사용하여 이메일 보내기
이러한 전자 메일이 Outlook에 동일한 대화로 나타나도록하려는 경우 대화보기를 사용할 때 이러한 전자 메일이 중첩/스레드되도록합니다. 그러나 이러한 이메일은 항상 새로운 대화로 나옵니다.
.subject 등과 비슷한 OutMail 변수의 속성을 설정하여 이메일이 중첩 된 것처럼 보이도록 항상 내 ConversationID/ConversationIndex를 만들 수 있습니까?
VBA 코드 :
Dim Source As Range 'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
Dim Dest As Workbook
Dim wb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim OutApp As Object
Dim OutMail As Object
Set Source = Nothing
On Error Resume Next
Set Source = Range("A1:AQ45").SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Source Is Nothing Then
MsgBox "The source is not a range or the sheet is protected, please correct and try again.", vbOKOnly
Exit Sub
End If
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set wb = ActiveWorkbook
Set Dest = Workbooks.Add(xlWBATWorksheet)
Source.Copy
With Dest.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
.Cells(1).PasteSpecial Paste:=xlPasteValues
.Cells(1).PasteSpecial Paste:=xlPasteFormats
.Cells(1).Select
Application.CutCopyMode = False
End With
TempFilePath = "C:\temp\"
TempFileName = "MyReport " & Format(Now, "yyyy-mm-dd hh-mm-ss")
FileExtStr = ".xlsx": FileFormatNum = 51
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With Dest
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
On Error Resume Next
End With
With Dest
With OutMail
.to = "[email protected]"
.CC = ""
.BCC = ""
.Subject = "Subject Report 1"
.HTMLBody = RangetoHTML(Range("A1:AQ45"))
.Attachments.Add Dest.FullName
.Send
End With
End With
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
With Dest
On Error GoTo 0
.Close savechanges:=False
End With
'ConversationID'와'ConversationIndex'는 모두 읽기 전용 속성입니다. 대화 내용을 보존해야하는 해당 메시지의 한 메시지에 대한 회신으로 기존 대화의 전자 메일을 처리하려고 시도하는 것이 좋습니다. –
강력하게 관련 : https://stackoverflow.com/q/8806882/321973 –
예보기 https://msdn.microsoft.com/en-us/library/ms527456(v=exchg.10).aspx –