메인 컨텐츠로 가기

여러 전자 메일의 모든 첨부 파일을 Outlook의 폴더에 저장하는 방법은 무엇입니까?

Outlook에 내장 된 모든 첨부 파일 저장 기능을 사용하면 이메일의 모든 첨부 파일을 쉽게 저장할 수 있습니다. 그러나 한 번에 여러 이메일의 모든 첨부 파일을 저장하려는 경우 직접적인 기능이 도움이 될 수 없습니다. 해당 이메일에서 모든 첨부 파일이 저장 될 때까지 각 이메일에 모든 첨부 파일 저장 기능을 반복적으로 적용해야합니다. 시간이 많이 걸립니다. 이 기사에서는 Outlook에서 여러 전자 메일의 모든 첨부 파일을 특정 폴더에 쉽게 대량 저장하는 두 가지 방법을 소개합니다.

VBA 코드로 여러 이메일의 모든 첨부 파일을 폴더에 저장
놀라운 도구를 사용하여 여러 이메일의 모든 첨부 파일을 폴더에 저장하려면 몇 번의 클릭


VBA 코드로 여러 이메일의 모든 첨부 파일을 폴더에 저장

이 섹션에서는 여러 전자 메일의 모든 첨부 파일을 특정 폴더에 한 번에 빠르게 저장하는 데 도움이되는 단계별 가이드의 VBA 코드를 보여줍니다. 다음과 같이하십시오.

1. 먼저 컴퓨터에 첨부 파일을 저장할 폴더를 만들어야합니다.

에 들어 가라. 서류 폴더를 만들고 이름이 지정된 폴더를 만듭니다. "첨부 파일". 스크린 샷을 참조하십시오 :

2. 첨부 파일을 저장할 이메일을 선택한 다음 다른 + F11 키를 눌러 응용 프로그램 용 Microsoft Visual Basic 창.

3. 클릭 끼워 넣다 > 모듈 를 열려면 모듈 창을 누른 다음 다음 VBA 코드 중 하나를 창에 복사합니다.

VBA 코드 1 : 여러 이메일의 첨부 파일 대량 저장 (정확히 동일한 이름의 첨부 파일을 직접 저장)

방문 꿀팁:이 코드는 파일 이름 뒤에 숫자 1, 2, 3 ...을 추가하여 정확히 동일한 이름 첨부 파일을 저장합니다.

Dim GCount As Integer
Dim GFilepath As String
Public Sub SaveAttachments()
'Update 20200821
Dim xMailItem As Outlook.MailItem
Dim xAttachments As Outlook.Attachments
Dim xSelection As Outlook.Selection
Dim i As Long
Dim xAttCount As Long
Dim xFilePath As String, xFolderPath As String, xSaveFiles As String
On Error Resume Next
xFolderPath = CreateObject("WScript.Shell").SpecialFolders(16)
Set xSelection = Outlook.Application.ActiveExplorer.Selection
xFolderPath = xFolderPath & "\Attachments\"
If VBA.Dir(xFolderPath, vbDirectory) = vbNullString Then
    VBA.MkDir xFolderPath
End If
GFilepath = ""
For Each xMailItem In xSelection
    Set xAttachments = xMailItem.Attachments
    xAttCount = xAttachments.Count
    xSaveFiles = ""
    If xAttCount > 0 Then
        For i = xAttCount To 1 Step -1
            GCount = 0
            xFilePath = xFolderPath & xAttachments.Item(i).FileName
            GFilepath = xFilePath
            xFilePath = FileRename(xFilePath)
            If IsEmbeddedAttachment(xAttachments.Item(i)) = False Then
                xAttachments.Item(i).SaveAsFile xFilePath
                If xMailItem.BodyFormat <> olFormatHTML Then
                    xSaveFiles = xSaveFiles & vbCrLf & "<Error! Hyperlink reference not valid.>"
                Else
                    xSaveFiles = xSaveFiles & "<br>" & "<a href='file://" & xFilePath & "'>" & xFilePath & "</a>"
                End If
            End If
        Next i
    End If
Next
Set xAttachments = Nothing
Set xMailItem = Nothing
Set xSelection = Nothing
End Sub

Function FileRename(FilePath As String) As String
Dim xPath As String
Dim xFso As FileSystemObject
On Error Resume Next
Set xFso = CreateObject("Scripting.FileSystemObject")
xPath = FilePath
FileRename = xPath
If xFso.FileExists(xPath) Then
    GCount = GCount + 1
    xPath = xFso.GetParentFolderName(GFilepath) & "\" & xFso.GetBaseName(GFilepath) & " " & GCount & "." + xFso.GetExtensionName(GFilepath)
    FileRename = FileRename(xPath)
End If
xFso = Nothing
End Function

Function IsEmbeddedAttachment(Attach As Attachment)
Dim xItem As MailItem
Dim xCid As String
Dim xID As String
Dim xHtml As String
On Error Resume Next
IsEmbeddedAttachment = False
Set xItem = Attach.Parent
If xItem.BodyFormat <> olFormatHTML Then Exit Function
xCid = ""
xCid = Attach.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F")
If xCid <> "" Then
    xHtml = xItem.HTMLBody
    xID = "cid:" & xCid
    If InStr(xHtml, xID) > 0 Then
        IsEmbeddedAttachment = True
    End If
End If
End Function
VBA 코드 2 : 여러 이메일의 첨부 파일 대량 저장 (중복 확인)
Public Sub SaveAttachments()
'Update 20200821
Dim xMailItem As Outlook.MailItem
Dim xAttachments As Outlook.Attachments
Dim xSelection As Outlook.Selection
Dim i As Long
Dim xAttCount As Long
Dim xFilePath As String, xFolderPath As String, xSaveFiles As String
Dim xYesNo As Integer
Dim xFlag As Boolean
On Error Resume Next
xFolderPath = CreateObject("WScript.Shell").SpecialFolders(16)
Set xSelection = Outlook.Application.ActiveExplorer.Selection
xFolderPath = xFolderPath & "\Attachments\"
If VBA.Dir(xFolderPath, vbDirectory) = vbNullString Then
    VBA.MkDir xFolderPath
End If
For Each xMailItem In xSelection
    Set xAttachments = xMailItem.Attachments
    xAttCount = xAttachments.Count
    xSaveFiles = ""
    If xAttCount > 0 Then
        For i = xAttCount To 1 Step -1
            xFilePath = xFolderPath & xAttachments.Item(i).FileName
            xFlag = True
            If VBA.Dir(xFilePath, 16) <> Empty Then
                xYesNo = MsgBox("The file is exists, do you want to replace it", vbYesNo + vbInformation, "Kutools for Outlook")
                If xYesNo = vbNo Then xFlag = False
            End If
            If xFlag = True Then
                xAttachments.Item(i).SaveAsFile xFilePath
                If xMailItem.BodyFormat <> olFormatHTML Then
                    xSaveFiles = xSaveFiles & vbCrLf & "<Error! Hyperlink reference not valid.>"
                Else
                    xSaveFiles = xSaveFiles & "<br>" & "<a href='file://" & xFilePath & "'>" & xFilePath & "</a>"
                End If
            End If
        Next i
    End If
Next
Set xAttachments = Nothing
Set xMailItem = Nothing
Set xSelection = Nothing
End Sub

노트:

1) 동일한 이름의 첨부 파일을 모두 폴더에 저장하려면 위의 내용을 적용하십시오. VBA 코드 1. 이 코드를 실행하기 전에 도구 > 참고자료을 클릭 한 다음 Microsoft 스크립팅 런타임 상자에 참조-프로젝트 대화 상자;

문서 저장 첨부 07

2) 중복 된 첨부 파일 이름을 확인하려면 VBA 코드를 적용하십시오. 2. 코드를 실행하면 중복 된 첨부 파일을 바꿀 것인지 묻는 대화 상자가 나타납니다. 가능 or 아니 필요에 따라.

5. 누르세요 F5 코드를 실행하는 키입니다.

그러면 선택한 이메일의 모든 첨부 파일이 1단계에서 만든 폴더에 저장됩니다. 

배송 시 요청 사항: 있을 수 있습니다 마이크로 소프트 아웃룩 팝업창이 뜨면 허용 계속하려면 버튼을 누르십시오.


놀라운 도구를 사용하여 여러 이메일의 모든 첨부 파일을 폴더에 저장

VBA의 초보자라면 여기에서 모든 첨부 파일 저장 ~의 유용성 Outook 용 Kutools 당신을 위해. 이 유틸리티를 사용하면 Outlook에서만 몇 번의 클릭으로 한 번에 여러 이메일의 모든 첨부 파일을 빠르게 저장할 수 있습니다.
기능을 적용하기 전에 먼저 Outlook 용 Kutools를 다운로드하고 설치하십시오..

1. 저장할 첨부 파일이 포함 된 이메일을 선택합니다.

팁 : 여러 개의 인접하지 않은 이메일을 선택할 수 있습니다. Ctrl 키 키를 누르고 하나씩 선택하십시오.
또는 변화 키를 누르고 첫 번째 이메일과 마지막 이메일을 선택하십시오.

2. 클릭 쿠툴 >부착 도구모두 저장. 스크린 샷보기 :

3. 에서 설정 저장 대화 상자에서 버튼을 눌러 첨부 파일을 저장할 폴더를 선택한 다음 OK 버튼을 클릭합니다.

3. 클릭 OK 다음 팝업 대화 상자에서 두 번, 그러면 선택한 이메일의 모든 첨부 파일이 지정된 폴더에 한 번에 저장됩니다.

배송 시 요청 사항:

  • 1. 이메일을 기준으로 첨부 파일을 다른 폴더에 저장하려면 다음 스타일로 하위 폴더 만들기 상자를 클릭하고 드롭 다운에서 폴더 스타일을 선택합니다.
  • 2. 모든 첨부 파일을 저장하는 것 외에도 특정 조건에 따라 첨부 파일을 저장할 수 있습니다. 예를 들어 파일 이름에 "Invoice"라는 단어가 포함 된 pdf 첨부 파일 만 저장하려면 고급 옵션 버튼을 눌러 조건을 확장 한 다음 아래 화면과 같이 구성합니다.
  • 3. 이메일이 도착했을 때 자동으로 첨부 파일을 저장하려면 첨부 파일 자동 저장 기능이 도움이 될 수 있습니다.
  • 4. 선택한 이메일에서 직접 첨부 파일을 분리하려면 모든 첨부 파일 분리 특징 Outlook 용 Kutools 너에게 호의를 베풀 수있다.

  이 유틸리티의 무료 평가판 (60 일)을 받으려면 그것을 다운로드하려면 클릭하십시오을 클릭 한 다음 위 단계에 따라 작업 적용으로 이동합니다.


관련 기사

Outlook의 전자 메일 메시지 본문에 첨부 파일 삽입
일반적으로 첨부 파일은 작성중인 이메일의 첨부 됨 필드에 표시됩니다. 이 자습서에서는 Outlook의 전자 메일 본문에 첨부 파일을 쉽게 삽입하는 데 도움이되는 방법을 제공합니다.

Outlook에서 특정 폴더로 첨부 파일을 자동으로 다운로드 / 저장
일반적으로 Outlook에서 첨부 파일> 모든 첨부 파일 저장을 클릭하여 한 전자 메일의 모든 첨부 파일을 저장할 수 있습니다. 그러나 수신 된 모든 이메일 및 수신 이메일의 모든 첨부 파일을 저장해야하는 경우 이상적인 것은 무엇입니까? 이 기사에서는 Outlook에서 특정 폴더로 첨부 파일을 자동으로 다운로드하는 두 가지 솔루션을 소개합니다.

Outlook에서 하나 / 여러 전자 메일의 모든 첨부 파일 인쇄
아시다시피 Microsoft Outlook에서 파일> 인쇄를 클릭하면 헤더, 본문과 같은 이메일 콘텐츠 만 인쇄되고 첨부 파일은 인쇄되지 않습니다. 여기서는 Microsoft Outlook에서 선택한 이메일의 모든 첨부 파일을 쉽게 인쇄하는 방법을 보여줍니다.

Outlook의 첨부 파일 (콘텐츠) 내의 검색 단어
Outlook의 빠른 검색 상자에 키워드를 입력하면 이메일 제목, 본문, 첨부 파일 등에서 키워드를 검색합니다.하지만 이제 Outlook에서만 첨부 파일 콘텐츠에서 키워드를 검색하면됩니다. 이 문서에서는 Outlook의 첨부 파일 콘텐츠 내에서 단어를 쉽게 검색하는 자세한 단계를 보여줍니다.

Outlook에서 회신 할 때 첨부 파일 유지
Microsoft Outlook에서 이메일 메시지를 전달할 때이 이메일 메시지의 원본 첨부 파일은 전달 된 메시지에 남아 있습니다. 그러나 이메일 메시지에 회신 할 때 원본 첨부 파일은 새 회신 메시지에 첨부되지 않습니다. 여기에서는 Microsoft Outlook에서 회신 할 때 원본 첨부 파일을 유지하는 방법에 대한 몇 가지 트릭을 소개합니다.


최고의 사무 생산성 도구

Outlook 용 Kutools - 귀하의 전망을 강화하는 100개 이상의 강력한 기능

🤖 AI 메일 도우미: AI 마법이 적용된 즉각적인 전문가 이메일 - 원클릭으로 천재적인 답변, 완벽한 어조, 다국어 숙달이 가능합니다. 손쉽게 이메일을 변환하세요! ...

📧 이메일 자동화: 부재중(POP 및 IMAP에서 사용 가능)  /  이메일 보내기 예약  /  이메일 발송 시 규칙에 따른 자동 참조/숨은참조  /  자동 전달(고급 규칙)   /  인사말 자동 추가   /  여러 수신자 이메일을 개별 메시지로 자동 분할 ...

📨 이메일 관리: 이메일을 쉽게 기억할 수 있습니다.  /  제목 및 기타 사기 이메일 차단  /  중복 이메일 삭제  /  고급 검색  /  폴더 통합 ...

📁 첨부 파일 프로일괄 저장  /  일괄 분리  /  일괄 압축  /  자동 저장   /  자동 분리  /  자동 압축 ...

🌟 인터페이스 매직: 😊더 예쁘고 멋진 이모티콘   /  탭 보기로 Outlook 생산성 향상  /  문을 닫는 대신 전망을 최소화하세요 ...

???? 원클릭 불가사의: 수신 첨부 파일과 함께 전체 회신  /   피싱 방지 이메일  /  🕘발신자의 시간대 표시 ...

👩🏼‍🤝‍👩🏻 연락처 및 캘린더: 선택한 이메일에서 연락처 일괄 추가  /  연락처 그룹을 개별 그룹으로 분할  /  생일 알림 제거 ...

이상 100 특징 당신의 탐험을 기다려주세요! 더 알아보려면 여기를 클릭하세요.

 

 

Comments (81)
Rated 3.5 out of 5 · 3 ratings
This comment was minimized by the moderator on the site
Thank you for sharing the code. Unfortunately, I tried both with failure. This is what I got - The macros in this project are disabled. Please refer to the online help or documentation of the host application to determine how to enable macros. Thank you.
This comment was minimized by the moderator on the site
Hi,
Please follow the instructions in the screenshot below to check if macros are enabled in the macro settings in your Outlook. After enabling both options, re-run the VBA code.

https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/macro-enabled.png
This comment was minimized by the moderator on the site
Thank you so much.
Rated 5 out of 5
This comment was minimized by the moderator on the site
Thank you for sharing VBA code. This work like magic and is going to save it lots of time!
This comment was minimized by the moderator on the site
Hello friends!

Thanks for sharing this VBA code.

Is there any way to change the location of the save folder?

I share the pc with some colleagues and in this case I need the files to be saved in a password protected folder which is not located in the documents folder.

How can I make this change?

Thank you in advance
This comment was minimized by the moderator on the site
Hi Fabiana,
Change the line 14
xFolderPath = xFolderPath & "\Attachments\"

to
xFolderPath = "C:\Users\Win10x64Test\Desktop\save attachments\1\"

Here "C:\Users\Win10x64Test\Desktop\save attachments\1\" is the folder path in my case.
Don't forget to end the folder path with a slash "\"
This comment was minimized by the moderator on the site
Hello friends!

Thank you for sharing that VBA code.

Is there any way to change the location of the save folder?

I share the pc with some colleagues and in this case I need the files to be saved in a password protected folder which is not located in the documents folder.

How can I make this change?

Thank you in advance
This comment was minimized by the moderator on the site
If you are trying to run the Code that renames duplicate files and keep getting a "User Type Not Defined" error message here is the code fixed. Instead of the "Dim xFso As FileSystemObject" on line 47 it should be "Dim xFso As Variant"
Also added a Message Box to appear at the end of data transfer.

Dim GCount As Integer
Dim GFilepath As String
Public Sub SaveAttachments()
'Update 20200821
Dim xMailItem As Outlook.MailItem
Dim xAttachments As Outlook.Attachments
Dim xSelection As Outlook.Selection
Dim i As Long
Dim xAttCount As Long
Dim xFilePath As String, xFolderPath As String, xSaveFiles As String
On Error Resume Next
xFolderPath = CreateObject("WScript.Shell").SpecialFolders(16)
Set xSelection = Outlook.Application.ActiveExplorer.Selection
xFolderPath = xFolderPath & "\Attachments\"
If VBA.Dir(xFolderPath, vbDirectory) = vbNullString Then
VBA.MkDir xFolderPath
End If
GFilepath = ""
For Each xMailItem In xSelection
Set xAttachments = xMailItem.Attachments
xAttCount = xAttachments.Count
xSaveFiles = ""
If xAttCount > 0 Then
For i = xAttCount To 1 Step -1
GCount = 0
xFilePath = xFolderPath & xAttachments.Item(i).FileName
GFilepath = xFilePath
xFilePath = FileRename(xFilePath)
If IsEmbeddedAttachment(xAttachments.Item(i)) = False Then
xAttachments.Item(i).SaveAsFile xFilePath
If xMailItem.BodyFormat <> olFormatHTML Then
xSaveFiles = xSaveFiles & vbCrLf & "<Error! Hyperlink reference not valid.>"
Else
xSaveFiles = xSaveFiles & "<br>" & "<a href='file://" & xFilePath & "'>" & xFilePath & "</a>"
End If
End If
Next i
End If
Next
Set xAttachments = Nothing
Set xMailItem = Nothing
Set xSelection = Nothing
MsgBoX prompt:="File Transfer Complete", Title:="Sweatyjalapenos tha Goat"
End Sub

Function FileRename(FilePath As String) As String
Dim xPath As String
Dim xFso As Variant
On Error Resume Next
Set xFso = CreateObject("Scripting.FileSystemObject")
xPath = FilePath
FileRename = xPath
If xFso.FileExists(xPath) Then
GCount = GCount + 1
xPath = xFso.GetParentFolderName(GFilepath) & "\" & xFso.GetBaseName(GFilepath) & " " & GCount & "." + xFso.GetExtensionName(GFilepath)
FileRename = FileRename(xPath)
End If
xFso = Nothing
End Function

Function IsEmbeddedAttachment(Attach As Attachment)
Dim xItem As MailItem
Dim xCid As String
Dim xID As String
Dim xHtml As String
On Error Resume Next
IsEmbeddedAttachment = False
Set xItem = Attach.Parent
If xItem.BodyFormat <> olFormatHTML Then Exit Function
xCid = ""
xCid = Attach.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F")
If xCid <> "" Then
xHtml = xItem.HTMLBody
xID = "cid:" & xCid
If InStr(xHtml, xID) > 0 Then
IsEmbeddedAttachment = True

End If
End If
End Function
This comment was minimized by the moderator on the site
Very nice script as of 2022-10-19 works great, for me doesn't seem to change original message by adding text. The only thing I changed is I added message received date time to each file name with the following format so it would nicely sort by date time in Windows folder: "yyyy-mm-dd HH-mm-ss ".

Code:

Dim GCount As Integer
Dim GFilepath As String
Public Sub SaveAttachments()
'Update 20200821
Dim xMailItem As Outlook.MailItem
Dim xAttachments As Outlook.Attachments
Dim xSelection As Outlook.Selection
Dim i As Long
Dim xAttCount As Long
Dim xFilePath As String, xFolderPath As String, xSaveFiles As String, xDateFormat As String
On Error Resume Next
xFolderPath = CreateObject("WScript.Shell").SpecialFolders(16)
Set xSelection = Outlook.Application.ActiveExplorer.Selection
xFolderPath = xFolderPath & "\Attachments\"
If VBA.Dir(xFolderPath, vbDirectory) = vbNullString Then
VBA.MkDir xFolderPath
End If
GFilepath = ""
For Each xMailItem In xSelection
Set xAttachments = xMailItem.Attachments
xAttCount = xAttachments.Count
xSaveFiles = ""
If xAttCount > 0 Then
For i = xAttCount To 1 Step -1
GCount = 0
xDateFormat = Format(xMailItem.ReceivedTime, "yyyy-mm-dd HH-mm-ss ")
xFilePath = xFolderPath & xDateFormat & xAttachments.Item(i).FileName
GFilepath = xFilePath
xFilePath = FileRename(xFilePath)
If IsEmbeddedAttachment(xAttachments.Item(i)) = False Then
xAttachments.Item(i).SaveAsFile xFilePath
If xMailItem.BodyFormat <> olFormatHTML Then
xSaveFiles = xSaveFiles & vbCrLf & "<Error! Hyperlink reference not valid.>"
Else
xSaveFiles = xSaveFiles & "<br>" & "<a href='file://" & xFilePath & "'>" & xFilePath & "</a>"
End If
End If
Next i
End If
Next
Set xAttachments = Nothing
Set xMailItem = Nothing
Set xSelection = Nothing
End Sub

Function FileRename(FilePath As String) As String
Dim xPath As String
Dim xFso As FileSystemObject
On Error Resume Next
Set xFso = CreateObject("Scripting.FileSystemObject")
xPath = FilePath
FileRename = xPath
If xFso.FileExists(xPath) Then
GCount = GCount + 1
xPath = xFso.GetParentFolderName(GFilepath) & "\" & xFso.GetBaseName(GFilepath) & " " & GCount & "." + xFso.GetExtensionName(GFilepath)
FileRename = FileRename(xPath)
End If
xFso = Nothing
End Function

Function IsEmbeddedAttachment(Attach As Attachment)
Dim xItem As MailItem
Dim xCid As String
Dim xID As String
Dim xHtml As String
On Error Resume Next
IsEmbeddedAttachment = False
Set xItem = Attach.Parent
If xItem.BodyFormat <> olFormatHTML Then Exit Function
xCid = ""
xCid = Attach.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F")
If xCid <> "" Then
xHtml = xItem.HTMLBody
xID = "cid:" & xCid
If InStr(xHtml, xID) > 0 Then
IsEmbeddedAttachment = True
End If
End If
End Function
This comment was minimized by the moderator on the site
Hi Oigo,
This is a very useful VBA script. Thank you for sharing it.
This comment was minimized by the moderator on the site
Hi crystal,

sorry for not being clear.

I was trying to use the code above mentioned. However, apparently I was doing something wrong. I was thinking that I might need to amend some parts in the code shown. For instance the path where to save the attachments and maybe some other parts. Therefore I was asking if you could share the code highlighting the parts which needs tailoring and how to tailor them.

Many thanks,
BR
This comment was minimized by the moderator on the site
Hi Rokkie,
Did you get any error prompt when the code runs? Or which line in your code is highlighted? I need more details so I can see where you can modify the code.
This comment was minimized by the moderator on the site
Hey crystal,

completeley new to this VBA. Can you share a code to use which shows where I have to amend with an example? As a Rookie it is a bit difficult to figure it out.

I am working via a Ctrix connection. Could this be a blocker for the macro?

Much appreaciate the help.
This comment was minimized by the moderator on the site
Hi Rookie,
Sorry I don't understand what you mean: "Can you share a code to use which shows where I have to amend with an example?"
And the code operates on selected emails in Outlook, Ctrix Connection does not block the macro.
This comment was minimized by the moderator on the site
Hi, I am running this Code 1 to extract .txt files from separate sub-folders of an inbox. It works great out of one sub-folder but not at all out of another sub-folder. I have tried forwarding the relevant email and attachment into other inboxes but no luck. The files are automatically generated and sent to the different sub-folders and only vary by a single letter in their title

Any help much is appreciated
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations