मुख्य सामग्री पर जाएं

आउटलुक में एकाधिक ईमेल से फ़ोल्डर में सभी अनुलग्नकों को कैसे सहेजें?

लेखक: सिलुविया अंतिम संशोधित: 2022-06-16

आउटलुक में बिल्ट-इन सेव ऑल अटैचमेंट फीचर के साथ ईमेल से सभी अटैचमेंट को सेव करना आसान है। हालाँकि, यदि आप एक साथ कई ईमेल से सभी अनुलग्नकों को सहेजना चाहते हैं, तो कोई प्रत्यक्ष सुविधा मदद नहीं कर सकती है। आपको प्रत्येक ईमेल में सभी अनुलग्नक सहेजें सुविधा को बार-बार लागू करने की आवश्यकता है जब तक कि उन ईमेल से सभी अनुलग्नक सहेजे न जाएं। यह समय लेने वाला है। इस आलेख में, हम आपके लिए एकाधिक ईमेल से सभी अनुलग्नकों को आउटलुक में एक विशिष्ट फ़ोल्डर में आसानी से सहेजने के लिए दो तरीकों का परिचय देते हैं।

एकाधिक ईमेल से सभी अनुलग्नकों को VBA कोड वाले फ़ोल्डर में सहेजें
एक अद्भुत टूल के साथ कई ईमेल से फ़ोल्डर में सभी अनुलग्नकों को सहेजने के लिए कई क्लिक


एकाधिक ईमेल से सभी अनुलग्नकों को VBA कोड वाले फ़ोल्डर में सहेजें

यह अनुभाग एक चरण-दर-चरण मार्गदर्शिका में एक VBA कोड प्रदर्शित करता है, जिससे आपको एक साथ कई ईमेल से सभी अनुलग्नकों को एक विशिष्ट फ़ोल्डर में शीघ्रता से सहेजने में मदद मिलती है। कृपया निम्नानुसार करें.

1. सबसे पहले, आपको अपने कंप्यूटर में अटैचमेंट को सेव करने के लिए एक फ़ोल्डर बनाना होगा।

में जाओ दस्तावेज़ फ़ोल्डर बनाएं और नाम का एक फ़ोल्डर बनाएं "संलग्नक"। स्क्रीनशॉट देखें:

2. उन ईमेल का चयन करें जिन्हें आप अटैचमेंट में सेव करेंगे और फिर दबाएँ ऑल्ट + F11 कुंजी को खोलने के लिए अनुप्रयोगों के लिए माइक्रोसॉफ्ट विज़ुअल बेसिक खिड़की.

3। क्लिक करें सम्मिलित करें > मॉड्यूल को खोलने के लिए मॉड्यूल विंडो, और फिर निम्न 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
वीबीए कोड 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) यदि आप सभी समान नाम वाले अनुलग्नकों को एक फ़ोल्डर में सहेजना चाहते हैं, तो कृपया उपरोक्त लागू करें वीबीए कोड 1. इस कोड को चलाने से पहले कृपया क्लिक करें टूल्स > संदर्भ, और फिर जाँच करें माइक्रोसॉफ्ट स्क्रिप्टिंग रनटाइम इन बॉक्स सन्दर्भ - परियोजना संवाद बकस;

दस्तावेज़ अनुलग्नक सहेजें07

2) यदि आप डुप्लिकेट अटैचमेंट नामों की जांच करना चाहते हैं, तो कृपया वीबीए कोड लागू करें 2। कोड चलाने के बाद, एक संवाद आपको याद दिलाने के लिए पॉप अप होगा कि डुप्लिकेट अटैचमेंट को बदलना है या नहीं, चुनें हाँ or नहीं अपनी आवश्यकताओं पर आधारित है।

5। दबाएं F5 कोड चलाने की कुंजी.

फिर चयनित ईमेल के सभी अनुलग्नक आपके द्वारा चरण 1 में बनाए गए फ़ोल्डर में सहेजे जाते हैं। 

टिप्पणियाँ: वहाँ एक हो सकता है माइक्रोसॉफ्ट आउटलुक प्रॉम्प्ट बॉक्स पॉप अप हो रहा है, कृपया क्लिक करें अनुमति देना आगे बढ़ने के लिए बटन.


एक अद्भुत टूल से एकाधिक ईमेल से सभी अनुलग्नकों को फ़ोल्डर में सहेजें

यदि आप वीबीए में नौसिखिया हैं, तो यहां इसकी अत्यधिक अनुशंसा की जाती है सभी अनुलग्नक सहेजें की उपयोगिता आउटुक के लिए कुटूल आपके लिए। इस उपयोगिता के साथ, आप केवल आउटलुक में कई क्लिक के साथ एक साथ कई ईमेल से सभी अनुलग्नकों को तुरंत सहेज सकते हैं।
कृपया सुविधा लागू करने से पहले सबसे पहले आउटलुक के लिए कुटूल डाउनलोड और इंस्टॉल करें.

1. उन ईमेल का चयन करें जिनमें वे अनुलग्नक हैं जिन्हें आप सहेजना चाहते हैं।

सुझाव: आप इसे दबाकर कई गैर-आसन्न ईमेल का चयन कर सकते हैं कंट्रोल कुंजी और उन्हें एक-एक करके चुनें;
या दबाकर एकाधिक आसन्न ईमेल का चयन करें पाली कुंजी और पहला ईमेल और अंतिम ईमेल चुनें।

2। क्लिक करें कुटूल >अनुलग्नक उपकरणशमादान जिसमें मोमबत्ती आखिर तक जल सके. स्क्रीनशॉट देखें:

3। में सेटिंग्स सहेजें संवाद, क्लिक करें अनुलग्नकों को सहेजने के लिए एक फ़ोल्डर का चयन करने के लिए बटन, और फिर क्लिक करें OK बटन.

3। क्लिक करें OK अगले संवाद बॉक्स में दो बार पॉप अप करें, फिर चयनित ईमेल में सभी अनुलग्नक एक ही बार में निर्दिष्ट फ़ोल्डर में सहेजे जाते हैं।

टिप्पणियाँ:

  • 1. यदि आप ईमेल के आधार पर अनुलग्नकों को विभिन्न फ़ोल्डरों में सहेजना चाहते हैं, तो कृपया जांचें निम्न शैली में सबफ़ोल्डर बनाएँ बॉक्स, और ड्रॉप-डाउन से एक फ़ोल्डर शैली चुनें।
  • 2. सभी अनुलग्नकों को सहेजने के अलावा, आप विशिष्ट शर्तों के अनुसार अनुलग्नकों को सहेज सकते हैं। उदाहरण के लिए, आप केवल पीडीएफ फ़ाइल अनुलग्नकों को सहेजना चाहते हैं जिनके फ़ाइल नाम में "चालान" शब्द है, कृपया क्लिक करें उन्नत विकल्प शर्तों का विस्तार करने के लिए बटन, और फिर नीचे दिखाए गए स्क्रीबशॉट के अनुसार कॉन्फ़िगर करें।
  • 3. यदि आप ईमेल आने पर अनुलग्नकों को स्वचालित रूप से सहेजना चाहते हैं, तो ऑटो सेव अटैचमेंट सुविधा मदद कर सकती है.
  • 4. चयनित ईमेल से सीधे अटैचमेंट को अलग करने के लिए सभी अनुलग्नकों को अलग करें का लक्षण आउटलुक के लिए कुटूल आप पर एक उपकार कर सकते हैं.

  यदि आप इस उपयोगिता का निःशुल्क परीक्षण (60-दिन) चाहते हैं, कृपया इसे डाउनलोड करने के लिए क्लिक करें, और फिर उपरोक्त चरणों के अनुसार ऑपरेशन लागू करने के लिए जाएं।


संबंधित लेख

आउटलुक में ईमेल संदेश के मुख्य भाग में अनुलग्नक सम्मिलित करें
आम तौर पर किसी कंपोजिंग ईमेल में अटैचमेंट अटैच्ड फ़ील्ड में प्रदर्शित होते हैं। यहां यह ट्यूटोरियल आपको आउटलुक में ईमेल बॉडी में आसानी से अटैचमेंट डालने में मदद करने के तरीके प्रदान करता है।

आउटलुक से एक निश्चित फ़ोल्डर में अटैचमेंट को स्वचालित रूप से डाउनलोड/सहेजें
सामान्यतया, आप आउटलुक में अटैचमेंट > सेव ऑल अटैचमेंट पर क्लिक करके एक ईमेल के सभी अटैचमेंट को सहेज सकते हैं। लेकिन, यदि आपको सभी प्राप्त ईमेल और प्राप्त ईमेल से सभी अनुलग्नकों को सहेजने की ज़रूरत है, तो कोई आदर्श? यह आलेख आउटलुक से एक निश्चित फ़ोल्डर में अनुलग्नकों को स्वचालित रूप से डाउनलोड करने के लिए दो समाधान पेश करेगा।

आउटलुक में सभी अनुलग्नकों को एक/एकाधिक ईमेल में प्रिंट करें
जैसा कि आप जानते हैं, जब आप Microsoft Outlook में फ़ाइल > प्रिंट पर क्लिक करेंगे तो यह केवल हेडर, बॉडी जैसी ईमेल सामग्री को प्रिंट करेगा, लेकिन अनुलग्नकों को प्रिंट नहीं करेगा। यहां हम आपको दिखाएंगे कि माइक्रोसॉफ्ट आउटलुक में किसी चयनित ईमेल में सभी अटैचमेंट को आसानी से कैसे प्रिंट किया जाए।

आउटलुक में अनुलग्नक (सामग्री) के भीतर शब्द खोजें
जब हम आउटलुक में त्वरित खोज बॉक्स में एक कीवर्ड टाइप करते हैं, तो यह ईमेल के विषयों, मुख्य भाग, अनुलग्नकों आदि में कीवर्ड खोजेगा। लेकिन अब मुझे केवल आउटलुक में अनुलग्नक सामग्री में कीवर्ड खोजने की ज़रूरत है, कोई विचार? यह आलेख आपको आउटलुक में अनुलग्नक सामग्री के भीतर शब्दों को आसानी से खोजने के विस्तृत चरण दिखाता है।

आउटलुक में उत्तर देते समय अनुलग्नक रखें
जब हम माइक्रोसॉफ्ट आउटलुक में एक ईमेल संदेश अग्रेषित करते हैं, तो इस ईमेल संदेश में मूल अनुलग्नक अग्रेषित संदेश में बने रहते हैं। हालाँकि, जब हम किसी ईमेल संदेश का उत्तर देते हैं, तो मूल अनुलग्नक नए उत्तर संदेश में संलग्न नहीं होंगे। यहां हम माइक्रोसॉफ्ट आउटलुक में उत्तर देते समय मूल अनुलग्नकों को रखने के बारे में कुछ तरकीबें पेश करने जा रहे हैं।


सर्वोत्तम कार्यालय उत्पादकता उपकरण

आउटलुक के लिए कुटूल - आपके आउटलुक को सुपरचार्ज करने के लिए 100 से अधिक शक्तिशाली सुविधाएँ

🤖 एआई मेल सहायक: एआई जादू के साथ त्वरित प्रो ईमेल - प्रतिभाशाली उत्तरों के लिए एक-क्लिक, सही टोन, बहुभाषी महारत। ईमेलिंग को सहजता से रूपांतरित करें! ...

📧 ईमेल स्वचालन: कार्यालय से बाहर (POP और IMAP के लिए उपलब्ध)  /  ईमेल भेजने का शेड्यूल करें  /  ईमेल भेजते समय नियमों के अनुसार ऑटो सीसी/बीसीसी  /  स्वतः अग्रेषित (उन्नत नियम)   /  स्वतः ग्रीटिंग जोड़ें   /  बहु-प्राप्तकर्ता ईमेल को स्वचालित रूप से अलग-अलग संदेशों में विभाजित करें ...

📨 ईमेल प्रबंधन: आसानी से ईमेल याद रखें  /  विषयों और अन्य लोगों द्वारा घोटाले वाले ईमेल को ब्लॉक करें  /  डुप्लिकेट ईमेल हटाएँ  /  उन्नत खोज  /  फ़ोल्डरों को समेकित करें ...

📁 अनुलग्नक प्रोबैच सहेजें  /  बैच अलग करना  /  बैच संपीड़न  /  ऑटो सहेजें   /  ऑटो डिटैच  /  ऑटो कंप्रेस ...

🌟 इंटरफ़ेस जादू: 😊अधिक सुंदर और शानदार इमोजी   /  टैब्ड व्यू के साथ अपनी आउटलुक उत्पादकता बढ़ाएँ  /  आउटलुक को बंद करने के बजाय छोटा करें ...

???? एक-क्लिक चमत्कार: आने वाले अनुलग्नकों के साथ सभी को उत्तर दें  /   फ़िशिंग-रोधी ईमेल  /  🕘प्रेषक का समय क्षेत्र दिखाएं ...

👩🏼‍🤝‍👩🏻 संपर्क एवं कैलेंडर: बैच चयनित ईमेल से संपर्क जोड़ें  /  किसी संपर्क समूह को अलग-अलग समूहों में विभाजित करें  /  जन्मदिन अनुस्मारक हटाएँ ...

के ऊपर 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