[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Renaming Outlook CSV Detachments

Posted on 2011-09-28
7
Medium Priority
?
265 Views
Last Modified: 2013-02-15
Hello Experts.  I am a newbie and trying to resolve this issue:

I am trying to create a file name for csv attachments that I am saving on the network.  

The format that I want to save the files is:

ReceivedTime less 1 day, formatted ddmmyyyy plus the file name

example:

file ABCDEF.CSV arrived today,  28 September, so the file saved with yesterdays date:

H:\\FOLDER1\FOLDER2\27092011 ABCDEF.CSV

Whilst I can get the file to detach and save, I am struggling to get the file name  correct file name.

I will be very grateful your help.


0
Comment
Question by:MagicMoggy
  • 3
  • 2
5 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 36730966
Hi, I think you'll be after something like this.

Regards,

Rob.
strFolder = "H:\FOLDER1\FOLDER2\"
If Right(strFolder, 1) <> "\" Then strFolder = strFolder & "\"

'....attach to your inbox and then go through the messages

For Each Item In Inbox.Items
	strTimeReceived = objMessage.TimeReceived
	dteYesterday = DateAdd("d", -1, CDate(strTimeReceived))
	strDate = Right("0" & Day(dteYesterday), 2) & Right("0" & Month(dteYesterday), 2) & Year(dteYesterday)
	For Each Atmt In Item.Attachments
		strFilePath = strFolder & strDate & " " & Atmt.FileName
		Atmt.SaveAsFile strFilePath
	Next
Next

Open in new window

0
 

Accepted Solution

by:
MagicMoggy earned 0 total points
ID: 36815789
Ron, thank you for your speedy reply.  I did have trouble with line 8, and after much time I realised that the solution was to simply knock off the value of 1 from the RecceivedTime, ensuring that the ((olkMessage.ReceivedTime - 1) was entered in brackets, (otherwise it did not deduct the value of 1).

'olkmessage as outlook mailitem,
              strDate = Strings.Format((olkMessage.ReceivedTime - 1), "ddmmyyyy") & " "
               strFilename = strDate & strFilename
               olkAttachment.SaveAsFile strRootFolderPath & strFilename

Again many thanks for your help.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 36818568
>> Strings.Format

Does that means your code is .NET?

Anyway, is that solved then, or is there something else you need?

Regards,

Rob.
0
 

Author Comment

by:MagicMoggy
ID: 36890271
I am a complete novice, but I believe it is VBA!!

Regards
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 36890982
OK.  I haven't seen that notation be able to be used in VBA, but if it works for you, then great!

I see you're new to EE.  Welcome!

Now if you have found your solution, you can select the comments that attributed to the answer, in order to close the question.

Thanks,

Rob.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question