여러 폴더 / 하위 폴더에서 전자 메일을 내보내 Outlook에서 뛰어나게하는 방법은 무엇입니까?
Outlook에서 가져 오기 및 내보내기 마법사를 사용하여 폴더를 내보낼 때 하위 폴더 포함 폴더를 CSV 파일로 내보내는 경우 옵션. 그러나 각 폴더를 CSV 파일로 내 보낸 다음 수동으로 Excel 통합 문서로 변환하는 것은 시간이 많이 걸리고 지루한 작업입니다. 이 기사에서는 여러 폴더와 하위 폴더를 Excel 통합 문서로 빠르게 내보내는 VBA를 소개합니다.
VBA를 사용하여 여러 폴더 / 하위 폴더의 여러 이메일을 Excel로 내보내기
- 자동 CC / BCC 이메일을 보낼 때 규칙에 따라; 자동 전달 규칙에 따른 여러 이메일; 자동 회신 교환 서버없이 더 많은 자동 기능 ...
- BCC 경고 -메일 주소가 숨은 참조 목록에있는 경우 모두 답장하려고 할 때 메시지를 표시합니다. 첨부 파일 누락시 알림및 기타 알림 기능 ...
- 모든 첨부 파일로 회신 (전체) 메일 대화에서; 한 번에 많은 이메일에 답장하십시오. 인사말 자동 추가 대답 할 때; 제목에 날짜 및 시간 자동 추가 ...
- 부착 도구: 자동 분리, 모두 압축, 모두 이름 바꾸기, 모두 자동 저장 ... 빠른 보고서, 선택한 메일 수, 중복 메일 및 연락처 제거 ...
- 100개 이상의 고급 기능이 대부분의 문제 해결 Outlook 2021 - 2010 또는 Office 365에서. 전체 기능은 60일 무료 평가판입니다.
VBA를 사용하여 여러 폴더 / 하위 폴더의 여러 이메일을 Excel로 내보내기
Outlook에서 VBA를 사용하여 여러 폴더 또는 하위 폴더의 전자 메일을 Excel 통합 문서로 내보내려면 아래 단계를 따르십시오.
1. 프레스 다른 + F11 키를 눌러 Microsoft Visual Basic for Applications 창을 엽니 다.
2. 클릭 끼워 넣다 > 모듈을 클릭 한 다음 VBA 코드 아래에 새 모듈 창에 붙여 넣습니다.
VBA : 여러 폴더 및 하위 폴더에서 Excel로 이메일 내보내기
Const MACRO_NAME = "Export Outlook Folders to Excel"
Sub ExportMain()
ExportToExcel "destination_folder_path\A.xlsx", "your_email_accouny\folder\subfolder_1"
ExportToExcel "destination_folder_path\B.xlsx", "your_email_accouny\folder\subfolder_2"
MsgBox "Process complete.", vbInformation + vbOKOnly, MACRO_NAME
End Sub
Sub ExportToExcel(strFilename As String, strFolderPath As String)
Dim olkMsg As Object
Dim olkFld As Object
Dim excApp As Object
Dim excWkb As Object
Dim excWks As Object
Dim intRow As Integer
Dim intVersion As Integer
If strFilename <> "" Then
If strFolderPath <> "" Then
Set olkFld = OpenOutlookFolder(strFolderPath)
If TypeName(olkFld) <> "Nothing" Then
intVersion = GetOutlookVersion()
Set excApp = CreateObject("Excel.Application")
Set excWkb = excApp.Workbooks.Add()
Set excWks = excWkb.ActiveSheet
'Write Excel Column Headers
With excWks
.Cells(1, 1) = "Subject"
.Cells(1, 2) = "Received"
.Cells(1, 3) = "Sender"
End With
intRow = 2
For Each olkMsg In olkFld.Items
'Only export messages, not receipts or appointment requests, etc.
If olkMsg.Class = olMail Then
'Add a row for each field in the message you want to export
excWks.Cells(intRow, 1) = olkMsg.Subject
excWks.Cells(intRow, 2) = olkMsg.ReceivedTime
excWks.Cells(intRow, 3) = GetSMTPAddress(olkMsg, intVersion)
intRow = intRow + 1
End If
Next
Set olkMsg = Nothing
excWkb.SaveAs strFilename
excWkb.Close
Else
MsgBox "The folder '" & strFolderPath & "' does not exist in Outlook.", vbCritical + vbOKOnly, MACRO_NAME
End If
Else
MsgBox "The folder path was empty.", vbCritical + vbOKOnly, MACRO_NAME
End If
Else
MsgBox "The filename was empty.", vbCritical + vbOKOnly, MACRO_NAME
End If
Set olkMsg = Nothing
Set olkFld = Nothing
Set excWks = Nothing
Set excWkb = Nothing
Set excApp = Nothing
End Sub
Public Function OpenOutlookFolder(strFolderPath As String) As Outlook.MAPIFolder
Dim arrFolders As Variant
Dim varFolder As Variant
Dim bolBeyondRoot As Boolean
On Error Resume Next
If strFolderPath = "" Then
Set OpenOutlookFolder = Nothing
Else
Do While Left(strFolderPath, 1) = "\"
strFolderPath = Right(strFolderPath, Len(strFolderPath) - 1)
Loop
arrFolders = Split(strFolderPath, "\")
For Each varFolder In arrFolders
Select Case bolBeyondRoot
Case False
Set OpenOutlookFolder = Outlook.Session.Folders(varFolder)
bolBeyondRoot = True
Case True
Set OpenOutlookFolder = OpenOutlookFolder.Folders(varFolder)
End Select
If Err.Number <> 0 Then
Set OpenOutlookFolder = Nothing
Exit For
End If
Next
End If
On Error GoTo 0
End Function
Function GetSMTPAddress(Item As Outlook.MailItem, intOutlookVersion As Integer) As String
Dim olkSnd As Outlook.AddressEntry
Dim olkEnt As Object
On Error Resume Next
Select Case intOutlookVersion
Case Is < 14
If Item.SenderEmailType = "EX" Then
GetSMTPAddress = SMTPEX(Item)
Else
GetSMTPAddress = Item.SenderEmailAddress
End If
Case Else
Set olkSnd = Item.Sender
If olkSnd.AddressEntryUserType = olExchangeUserAddressEntry Then
Set olkEnt = olkSnd.GetExchangeUser
GetSMTPAddress = olkEnt.PrimarySmtpAddress
Else
GetSMTPAddress = Item.SenderEmailAddress
End If
End Select
On Error GoTo 0
Set olkPrp = Nothing
Set olkSnd = Nothing
Set olkEnt = Nothing
End Function
Function GetOutlookVersion() As Integer
Dim arrVer As Variant
arrVer = Split(Outlook.Version, ".")
GetOutlookVersion = arrVer(0)
End Function
Function SMTPEX(olkMsg As Outlook.MailItem) As String
Dim olkPA As Outlook.propertyAccessor
On Error Resume Next
Set olkPA = olkMsg.propertyAccessor
SMTPEX = olkPA.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x5D01001E")
On Error GoTo 0
Set olkPA = Nothing
End Function
3. 필요에 따라 위의 VBA 코드를 조정하십시오.
(1) 교체 대상_폴더_경로 위 코드에서 대상 폴더의 폴더 경로와 함께 내 보낸 통합 문서를 다음과 같이 저장할 것입니다. C : \ 사용자 \ DT168 \ 문서 \ TEST.
(2) 위 코드에서 your_email_accouny \ folder \ subfolder_1 및 your_email_accouny \ folder \ subfolder_2를 Outlook의 하위 폴더 경로로 바꿉니다. 켈리 @extendoffice.com \ Inbox \ A 및 켈리 @extendoffice.com \ Inbox \ B
4. 누르세요 F5 키를 누르거나 달리기 버튼을 눌러이 VBA를 실행합니다. 그런 다음 OK Outlook 폴더를 Excel로 내보내기 대화 상자가 나타납니다. 스크린 샷보기 :
이제 위의 VBA 코드에 지정된 모든 하위 폴더 또는 폴더의 전자 메일이 내보내지고 Excel 통합 문서에 저장됩니다.
관련 기사
Outlook 용 Kutools-Outlook에 100 개의 고급 기능을 제공하고 작업을 훨씬 더 쉽게 만듭니다!
- 자동 CC / BCC 이메일을 보낼 때 규칙에 따라; 자동 전달 사용자 정의에 의한 여러 이메일; 자동 회신 교환 서버없이 더 많은 자동 기능 ...
- BCC 경고 -모두 답장하려고 할 때 메시지 표시 메일 주소가 숨은 참조 목록에있는 경우; 첨부 파일 누락시 알림및 기타 알림 기능 ...
- 메일 대화에서 모든 첨부 파일로 (전체) 회신; 많은 이메일에 답장 초 안에; 인사말 자동 추가 대답 할 때; 제목에 날짜 추가 ...
- 첨부 도구 : 모든 메일의 모든 첨부 파일 관리, 자동 분리, 모두 압축, 모두 이름 바꾸기, 모두 저장 ... 빠른 보고서, 선택한 메일 수...
- 강력한 정크 메일 관습에 의해; 중복 메일 및 연락처 제거... Outlook에서 더 스마트하고 빠르며 더 나은 작업을 수행 할 수 있습니다.











