format date

rollingzep

Board Regular
Joined
Nov 18, 2013
Messages
214
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I am trying to save Outlook email attachments but looking for the mails with subject as HO Reports/Divn EOD yyyy-mm-dd
The yyyy-mm-dd are the previous working day date. On Mondays, I receive the previous working day(Friday) date on the subject.
How do I format this?

VBA Code:
For Each olMail In OlItems

        If olMail.subject Like "*HO Reports/Divn EOD [B]yyyy-mm-dd[/B]*" Then

        strFile = olMail & ".zip"

TIA
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try using
VBA Code:
If olMail.subject Like "*HO Reports/Divn EOD " & Format(Application.WorksheetFunction.WorkDay(Date, -1), "yyyy-mm-dd") & "*" Then
 
Upvote 0
Try using
VBA Code:
If olMail.subject Like "*HO Reports/Divn EOD " & Format(Application.WorksheetFunction.WorkDay(Date, -1), "yyyy-mm-dd") & "*" Then
That works but it does not identify the .zip file attachment.
1695910063101.png

at the line, strFile = olMail & ".zip"

My intention is to save the zip file which is an attachment in the mail to a local folder and then to unzip it to another folder.
The zip file has 10 files, of which I need three files.

TIA
 
Upvote 0
So ther is another problem in the macro.
Could you show the full code? I wonder what type of "object" is olMail, hardly it is a string one...
 
Upvote 0

Forum statistics

Threads
1,215,106
Messages
6,123,124
Members
449,097
Latest member
mlckr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top