Go Back   AnandTech Forums > Software > Programming

Forums
· Hardware and Technology
· CPUs and Overclocking
· Motherboards
· Video Cards and Graphics
· Memory and Storage
· Power Supplies
· Cases & Cooling
· SFF, Notebooks, Pre-Built/Barebones PCs
· Networking
· Peripherals
· General Hardware
· Highly Technical
· Computer Help
· Home Theater PCs
· Consumer Electronics
· Digital and Video Cameras
· Mobile Devices & Gadgets
· Audio/Video & Home Theater
· Software
· Software for Windows
· All Things Apple
· *nix Software
· Operating Systems
· Programming
· PC Gaming
· Console Gaming
· Distributed Computing
· Security
· Social
· Off Topic
· Politics and News
· Discussion Club
· Love and Relationships
· The Garage
· Health and Fitness
· Home and Garden
· Merchandise and Shopping
· For Sale/Trade
· Hot Deals with Free Stuff/Contests
· Black Friday 2014
· Forum Issues
· Technical Forum Issues
· Personal Forum Issues
· Suggestion Box
· Moderator Resources
· Moderator Discussions
   

Reply
 
Thread Tools
Old 11-01-2012, 03:28 AM   #1
Xyseven
Junior Member
 
Join Date: Nov 2012
Posts: 2
Default Outlook VBA script to save file with subject as filename

Good day. New member here

Long story short:
I would like a script that grabs the attachments from a incoming mails and saves them in a specified folder with the subject as the filename.

The bigger picture:
I regularly recieve mails with attached pdf files. The pdf filename is always called "Vedlegg" ("attachement" in norwegian) and the subject field is always "ARBEIDSORDRE 589492/2012 ,VH35682 ,FORHÅNDSVIS" except for the numbers being different each time. I work in a car workshop and these pdf's are work-orders containing a description of what to repair on the different cars. Thus the numbers will be different on each mail, but I want them to be automatically stored with the subject field as the filename.

Also, I am aware that "/" can not be used in filenames. So I would like something that inserts a space instead and also maybe deletes the first and last word "ARBEIDSORDRE" and "FORHÅNDSVIS" as those are of no interest when I later want to search for it.

Kind Regards
-Xy-

Last edited by Xyseven; 11-01-2012 at 03:34 AM.
Xyseven is offline   Reply With Quote
Old 11-03-2012, 02:03 PM   #2
Ken g6
Elite Member
 
Ken g6's Avatar
 
Join Date: Dec 1999
Location: Colorado
Posts: 8,957
Default

OK, so what programming languages do you know that might have a POP3 or IMAP library?

Edit: I always miss the title.
__________________
Look for really BIG primes with TeAm AnandTech PrimeGrid!
Next race: Now - November 24

Last edited by Ken g6; 11-03-2012 at 02:34 PM.
Ken g6 is online now   Reply With Quote
Old 11-03-2012, 04:25 PM   #3
coloumb
Diamond Member
 
coloumb's Avatar
 
Join Date: Oct 1999
Location: Northwest
Posts: 4,087
Default

You might want to try here as well [seems to be a bit more active community]:

http://social.technet.microsoft.com/...gory/scripting

I don't think it would be too difficult to program...
__________________
[<><><><>}================================
This sounds like fun. I will enjoy "bending" her to my will...
coloumb is offline   Reply With Quote
Old 11-05-2012, 05:05 AM   #4
Xyseven
Junior Member
 
Join Date: Nov 2012
Posts: 2
Default

Thank you for the quick reply. I have no knowledge of VBA or any programming at all. My job is with automobilenetworking and hardware But I will try that forum you linked - thanks!


I am using this today (which does almost what I want):

Sub SaveAllAttachments(objitem As MailItem)

Dim objAttachments As Outlook.Attachments
Dim strName, strLocation As String
Dim dblCount, dblLoop As Double
strLocation = "KNy mappe struktur\Servicemarked\Volkswagen og Audi verksted\Gjennomganger - Teksteark\Jack\"

On Error GoTo ExitSub
If objitem.Class = olMail Then
Set objAttachments = objitem.Attachments
dblCount = objAttachments.Count
If dblCount <= 0 Then
GoTo 100
End If
For dblLoop = 1 To dblCount
strID = " from " & Format(Date, "mm-dd-yy")
strName = objAttachments.Item(dblLoop).Filename 'Get attachment name
strExt = Right$(strName, 4) 'Store file Extension
strName = Left$(strName, Len(strName) - 4) 'Remove file Extension
strName = strName & strID & strExt 'Reattach Extension
strName = strLocation & strName
objAttachments.Item(dblLoop).SaveAsFile strName
Next dblLoop
'objitem.Delete
End If
100
ExitSub:
Set objAttachments = Nothing
Set objOutlook = Nothing

End Sub
Xyseven is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 04:16 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.