Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / General MS Outlook Questions / August 2007

Tip: Looking for answers? Try searching our database.

Editing the creation date in visual basic

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jelly Belly - 20 Aug 2007 19:52 GMT
Hello, first question, but I've been lurking for a while.  This is a great
resource for people learning how to code by the way.

We receive an email every day and I've set up a VB script to run that saves
the file with the creation date in the file name.  The problem is the
creation date is T+1 the actual date of the attached file.  For example the
script will save a file with 08.17.07 in the file name, but I actually want
08.16.07.

Is there a way to edit the code to name the file with the creation date -1
day to properly name the file?

Thanks a lot
Jelly Belly - 20 Aug 2007 19:56 GMT
By the way, this is the code I'm using, gleaned from this very helpful
website http://www.fontstuff.com/outlook/oltut01.htm

Sub JellySwaps(MyMail As MailItem)
   Dim strID As String
   Dim olNS As Outlook.NameSpace
   Dim olMail As Outlook.MailItem
   Dim atmt As Attachment
   Dim date as string

   strID = MyMail.EntryID
   Set olNS = Application.GetNamespace("MAPI")
   Set olMail = olNS.GetItemFromID(strID)
Set date = format(olmail.creationtime, "mm.dd "

   MsgBox olMail.Subject
   For Each atmt In olMail.Attachments
               FileName = "C:\test\" & _
                   date & "jelly.pdf"
                   atmt.SaveAsFile FileName

   Next atmt
   
   Set olMail = Nothing
   Set olNS = Nothing
End Sub

> Hello, first question, but I've been lurking for a while.  This is a great
> resource for people learning how to code by the way.
[quoted text clipped - 9 lines]
>
> Thanks a lot
Diane Poremsky [MVP] - 20 Aug 2007 20:39 GMT
are you including the time zone offset in the calculation?

Signature

Diane Poremsky [MVP - Outlook]
Author, Teach Yourself Outlook 2003 in 24 Hours
Need Help with Common Tasks? http://www.outlook-tips.net/beginner/
Outlook 2007: http://www.slipstick.com/outlook/ol2007/

Outlook Tips by email:
dailytips-subscribe-request@lists.outlooktips.net

Outlook Tips: http://www.outlook-tips.net/
Outlook & Exchange Solutions Center: http://www.slipstick.com
Subscribe to Exchange Messaging Outlook newsletter:
EMO-NEWSLETTER-SUBSCRIBE-REQUEST@PEACH.EASE.LSOFT.COM

> Hello, first question, but I've been lurking for a while.  This is a great
> resource for people learning how to code by the way.
[quoted text clipped - 12 lines]
>
> Thanks a lot
Ken Slovak - [MVP - Outlook] - 20 Aug 2007 20:41 GMT
The best place for programming questions is one of the developer groups such
as program_vba, down the hall.

You can't change the CreationTime property, that's read-only to your code.
You can get item.CreationTime and use the DateAdd method to add 1 day to the
date you get back. Use the Help to look up the syntax for the DateAdd
method.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Hello, first question, but I've been lurking for a while.  This is a great
> resource for people learning how to code by the way.
[quoted text clipped - 12 lines]
>
> Thanks a lot
Jelly Belly - 20 Aug 2007 22:02 GMT
Hi Ken, I used the Dateadd method to subtract a day from the creation date
and populate file name, thanks for pointing me in the right direction.

> The best place for programming questions is one of the developer groups such
> as program_vba, down the hall.
[quoted text clipped - 20 lines]
> >
> > Thanks a lot
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.