Solved

Renaming Outlook CSV Detachments

Posted on 2011-09-28
7
248 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Search inbox emails for multiple words in Outlook 2010 2 46
exchange , email 8 38
Outlook Automation in Access Using "Find" 2 53
Modify Text File with Excel Macro 13 43
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
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…

738 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