여러 폴더 / 하위 폴더에서 전자 메일을 내보내 Outlook에서 뛰어나게하는 방법은 무엇입니까?
Outlook에서 가져 오기 및 내보내기 마법사를 사용하여 폴더를 내보낼 때 하위 폴더 포함 폴더를 CSV 파일로 내보내는 경우 옵션. 그러나 각 폴더를 CSV 파일로 내 보낸 다음 수동으로 Excel 통합 문서로 변환하는 것은 시간이 많이 걸리고 지루한 작업입니다. 이 기사에서는 여러 폴더와 하위 폴더를 Excel 통합 문서로 빠르게 내보내는 VBA를 소개합니다.
VBA를 사용하여 여러 폴더 / 하위 폴더의 여러 이메일을 Excel로 내보내기
- 이메일을 자동화하세요 자동 CC / BCC, 자동 전달 규칙에 따라; 보내다 자동 회신 (부재중) 교환서버 필요없이...
- 다음과 같은 알림을 받으세요 BCC 경고 BCC 목록에 있는 동안 모든 항목에 답장할 때 첨부 파일 누락시 알림 잊어버린 첨부파일을 위해...
- 이메일 효율성 향상 첨부 파일을 포함하여 회신(전체), 서명이나 제목에 인사말이나 날짜 및 시간 자동 추가, 여러 이메일에 답장하기...
- 이메일 전송을 간소화하세요 리콜 이메일, 부착 도구 (모두 압축, 모두 자동 저장...), 중복 제거및 빠른 보고서...
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의 하위 폴더 경로로 바꿉니다. \받은 편지함\A 과 \받은 편지함\B
4. 누르세요 F5 키를 누르거나 달리기 버튼을 눌러이 VBA를 실행합니다. 그런 다음 OK Outlook 폴더를 Excel로 내보내기 대화 상자가 나타납니다. 스크린 샷보기 :
이제 위의 VBA 코드에 지정된 모든 하위 폴더 또는 폴더의 전자 메일이 내보내지고 Excel 통합 문서에 저장됩니다.
관련 기사
최고의 사무 생산성 도구
Outlook 용 Kutools - 귀하의 전망을 강화하는 100개 이상의 강력한 기능
🤖 AI 메일 도우미: AI 마법이 적용된 즉각적인 전문가 이메일 - 원클릭으로 천재적인 답변, 완벽한 어조, 다국어 숙달이 가능합니다. 손쉽게 이메일을 변환하세요! ...
📧 이메일 자동화: 부재중(POP 및 IMAP에서 사용 가능) / 이메일 보내기 예약 / 이메일 발송 시 규칙에 따른 자동 참조/숨은참조 / 자동 전달(고급 규칙) / 인사말 자동 추가 / 여러 수신자 이메일을 개별 메시지로 자동 분할 ...
📨 이메일 관리: 이메일을 쉽게 기억할 수 있습니다. / 제목 및 기타 사기 이메일 차단 / 중복 이메일 삭제 / 고급 검색 / 폴더 통합 ...
📁 첨부 파일 프로: 일괄 저장 / 일괄 분리 / 일괄 압축 / 자동 저장 / 자동 분리 / 자동 압축 ...
🌟 인터페이스 매직: 😊더 예쁘고 멋진 이모티콘 / 탭 보기로 Outlook 생산성 향상 / 문을 닫는 대신 전망을 최소화하세요 ...
???? 원클릭 불가사의: 수신 첨부 파일과 함께 전체 회신 / 피싱 방지 이메일 / 🕘발신자의 시간대 표시 ...
👩🏼🤝👩🏻 연락처 및 캘린더: 선택한 이메일에서 연락처 일괄 추가 / 연락처 그룹을 개별 그룹으로 분할 / 생일 알림 제거 ...
이상 100 특징 당신의 탐험을 기다려주세요! 더 알아보려면 여기를 클릭하세요.