Nested email attachments

Status
Not open for further replies.

Dan_W

Member
Outlook version
Outlook 2016 32 bit
Email Account
Outlook.com (as MS Exchange)
Hello,

I've been visiting these forums for some time now, and I've always managed to solve whatever challenges I've had with my code, but I'm slightly stumped with the logic (at least) of what it is I'm trying to do with a macro in Outlook. I would be grateful for any guidance or suggestions, because as much as I google it, I can't quite find the right answer.

I expect the code would be straightforward, but I just can't wrap my head around the logic of it. In essence:

1. User selects a number of email - these emails will each have attachments to them.
2. The emails and the attachments are downloaded to the local drive.
3. HOWEVER, it is likely that these attachments are a mix of both MSG ("Attachment Email") and standard attachments (e.g., DOCX, PDF, etc).
4, The macro then needs to save the attachments to the Attachment Emails, until all the attachments are saved.
5. THEN, all of the Attachment Emails need to be sorted chronologically, and arranged/printed in order. If there is an attachment to an Attachment Email, that will need to sit appended to the corresponding parent email.

Saving the attachments to the hard drive is ok (.SaveAsFile), thank you Slipstick (Saving Attachments to the Hard Drive). I'm stuck on the sorting part. Do I reimport the MSG files back into Outlook? CreateItemFromTemplate and then sort and then re-export?

I feel like I'm over thinking this.

Again, any guidance would be greatly appreciated. Thank you.

Dan
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I dont think importing/exporting will help - its not going to fix windows sorting. Windows sorts by created, saved or mod date - the emails will use the date you saved them. I would get the date from the message and either add it to the filename or update the filesystem properties so you can sort by a property field.
 

Dan_W

Member
Outlook version
Outlook 2016 32 bit
Email Account
Outlook.com (as MS Exchange)
Hi Diane

I only just managed to come back to this forum this evening owing to work demands, so I apologise for not replying earlier.

Thank you for taking the effort to set out your thoughts - as it so happens I stumbled across the perfect solution by accident an hour or so after having posted the question on this forum. The short story is:-

1. I was overthinking it; and
2. You were absolutely right - the key was to add a date/timestamp at the front of filenames (yyyymmdd-hhmmss).

The subroutine works its way through each email in the selection, saves it to the designated folder with a filename composed of the date/time of the email and the subject of email (stripped of illegal characters): (yyyymmdd-hhmmss_SubjectOfEmail.msg).

If that email had any attachments, then those attachments are saved to the designated folder with a filename composed of the date/time of the parent email and then its actual filename unless the relevant attachment was itself an MSG file, in which case it would set about going through the process again recursively, but this time with its own date/time as the working date/timestamp. The final result was several hundred documents in a folder, all perfectly arranged chronologically.

It turns out that the total count was 56 emails (parent emails + nested emails), and the total non-MSG attachments was 228 documents. Needless to say, this saved us a lot of time.

I will look into cleaning up the code and posting it for others to use (or critique). Thank you again.
 

andrew fawcett

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
Hi - sorry to ask a stupid question about attachments, but having trouble starting a new question, so thought it better to write on the above subject.

When i make a task, i always initially insert a copy of the email that i have received into that task using a quickstep to 'Make a Task with attachment' When i get extra emails about the same task, i 'insert outlook item' into that task. This way i can track the complete task without having to go anywhere else. Easy.

My problem is that additionally to the 'insert outlook item' that is being done, i also want to forward the message that im 'inserting' into an email to a separate person. I know that this can be done via an outlook quickstep, but i want both of the actions to be done at the same time, and the quickstep cannot do both. Not being terribly up to speed with VBA, do you have any templates that i might borrow and tweak to allow both the actions to be done please. Any help gratefully appreciated.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
you can use this as a base then add code to forward.

Using first macro, add forward code after the end with:

Code:
With objTask
    .Subject = objMail.Subject
    .DueDate = objMail.ReceivedTime + 3
    .StartDate = objMail.ReceivedTime + 2
     objSel.PasteAndFormat (wdFormatOriginalFormatting)
    .Categories = "From Email"
   ' .Save
    .Save
    .Display
    .Attachments.Add objMail
End With

    objMail.Categories = "Task" & objMail.Categories

Forward code would be:

Code:
Set objForward = objMail.Forward
oForward.display

If you always forward to the same address, you can add the address and send it too.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
M Question about nested distribution lists Outlook VBA and Custom Forms 3
E Duplicate, nested account folders on ATT server Using Outlook 10
M Nested distribution lists: how to count UNIQUE # of people... Outlook VBA and Custom Forms 13
A From a Nested Contact Folder Structure to a Categorised Contact Structure Using Outlook 2
B Deleting Nested Attachments Using Outlook 2
2 Nested or Hierarchical tasks in Outlook 2010? Using Outlook 1
R Roadrunner Email Problems | Roadrunner Technical Service Number Outlook VBA and Custom Forms 0
V Macro to mark email with a Category Outlook VBA and Custom Forms 4
R Roadrunner Email Settings | Contact Roadrunner Customer Support Outlook VBA and Custom Forms 0
D Gmail mail is being delivered to a different email inbox in Outlook App 2021 Using Outlook 2
Albert McCann Outlook 2021 Outlook Display of HTML Email from two senders is glitchy Using Outlook 0
A How Do I Setup My Optonline.Net Email Account? Outlook VBA and Custom Forms 1
H Preventing the 'email address fetch from Exchange' crashing email reading code Exchange Server Administration 0
D multiple email accounts - why do I have to choose the "from" account address?? Using Outlook 2
Wotme create email only data file Using Outlook 1
F Outlook 2016 Email with attachments not being received Using Outlook 2
J Outlook 2019 Regex email addresses from body Outlook VBA and Custom Forms 6
D Prompt to prefix subject line whenever sending an email Outlook VBA and Custom Forms 3
J Quick steps delete original email and move reply/sent email to folder Using Outlook 2
C Wishlist Extract or scan new email addresses from out of office replies. Leads from OOO replies Using Outlook 1
T External email warning banner Outlook VBA and Custom Forms 0
A Links in email getting error message about group policy Using Outlook 4
richardwing Auto forward email that is moves into a specific outlook folder Outlook VBA and Custom Forms 5
J Recommendations for Outlook Duplicate Email Remover Using Outlook 6
Geldner Tweak Junk Email Reporting tool to default to particular email on send? Using Outlook 3
S Outlook 365 Can I change the possible range of highlighting colours when writing an Outlook email? Using Outlook 1
V Can one change the formatting of email title blocks? Using Outlook 0
P default font when sending email from browser Using Outlook 1
D VBA Macro to Print and Save email to network location Outlook VBA and Custom Forms 1
B IMAP server rejects sent email - cannot deliver messages Using Outlook 2
TedSch Small vba to kill political email Outlook VBA and Custom Forms 3
X Open Hyperlinks in an Outlook Email Message (Help with Diane's solution) Outlook VBA and Custom Forms 3
e_a_g_l_e_p_i Email notifications changed with Outlook 2021 Using Outlook 8
glnz How to retrieve or redo Verizon.net email password without affecting Outlook connection? Using Outlook 1
Z Copy specific email body text Outlook VBA and Custom Forms 0
D ISOmacro to extract active mail senders name and email, CC, Subject line, and filename of attachments and import them into premade excel spread sheet Outlook VBA and Custom Forms 2
M Outlook 365 refuses to send email Using Outlook 1
B Search and Find Email by Folder Name Outlook VBA and Custom Forms 2
K Closing external IMAP email... Outlook 2013 Using Outlook 0
L Capture email addresses and create a comma separated list Outlook VBA and Custom Forms 5
C Email bomb processing Outlook VBA and Custom Forms 1
O What would be the recommended way to change an email address (family member)? Using Outlook 0
A Outlook 2016 Macro to Reply, ReplyAll, or Forward(but with composing new email) Outlook VBA and Custom Forms 0
L Checking Sender Email Address for trusted domain from list on intranet Outlook VBA and Custom Forms 4
J How do you disable address search box when typing @ in body of email? Using Outlook 0
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
Victor.Ayala Automated way to check the option "Show this folder as an email Address Book" Outlook VBA and Custom Forms 2
D Wrong email address in Outlook 2003 "From" tab in new outgoing emails Using Outlook 4
D Forwarding email based on the attachment file type and specific text found on the attachment file name Outlook VBA and Custom Forms 1
F Forward incoming email with 4 embedded images in the body without original sender Outlook VBA and Custom Forms 22

Similar threads

Top