vba - Remove email attachments after saving them and adding save location to email in Outlook -
I created this macro from which I do the following:
- Choose a folder < / Li>
Select the date range to download email attachments
After the email has been saved, I need to delete an email saved attachment and change it. is . Resume
option to clear the following sub-SaveMailAttachments (): With the link to the location where it was saved here the code I have been using the namespace set ns = GetNamespace ("MAPI") set the inbox MAPIFolder inbox = ns.GetDefaultFolder (olFolderInbox) Dim SaveFolder string as the dull subfolder MAPIFolder dim item item dim as attachment dim file name In the form of a string, fName as Attached Stri In the form of slow dimd as I recite the slowed searchdate string as SentDate as the string slow sntDate as the date searchdate = InputBox attac ("Enter a previous date to search from" ") SaveFolder = BrowseForFolder (" Select the folder for hments you would like to save. ") If saveFolder = vbNullString then exit sub-I = 0 Inbox.Items.Count = 0 then there are MsgBox" In any message in the inbox Not. ", VbInformation, _" Nothing Found "Exit the sub-end then start the error again. In the next Inbox.Items sntDate = Item.SentOn SentDate = Format Each item (sntDate," dd / mm / yyyy ") for each item.Attachments Engage in Searchdate & lt Are; SentDate then FileName = saveFolder & amp; "\" & Amp; Attach. Attach the filename. Save file file name I = I + 1 end if the next attachment 'end if the next item and sub
Delete an attachment, call attachment Delete You may want to use i / i for attachments. After deleting an attachment, instead of "for each", the line loop collection count for 1 step-1 will change. You can also check attachment extensions / etc. First make sure that you are not removing the embedded HTML image attachment.
To insert attachment as a reference, call Attachments.Add to specify the new attachment location, but olByReference passes as the second parameter.
Comments
Post a Comment