Hypothetical Outlook Question

User avatar
Joseph
3StarLounger
Posts: 206
Joined: 31 Dec 2010, 22:23
Location: Columbia Falls, MT

Hypothetical Outlook Question

Post by Joseph »

If I am accessing Outlook via Citrix, and my drive partition is on the same server. Would it be at all possible to email Excel files directly to a file path? Probably not...

User avatar
HansV
Administrator
Posts: 78229
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Hypothetical Outlook Question

Post by HansV »

You e-mail messages to a recipient, you don't e-mail files to a folder, so I'm not sure what exactly you mean...
Best wishes,
Hans

User avatar
Joseph
3StarLounger
Posts: 206
Joined: 31 Dec 2010, 22:23
Location: Columbia Falls, MT

Re: Hypothetical Outlook Question

Post by Joseph »

I suppose what I'm curious on is this. Can you use vba to auto save specific files to specific locations once they hit your inbox?

User avatar
HansV
Administrator
Posts: 78229
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Hypothetical Outlook Question

Post by HansV »

It's possible to write a script (VBA or otherwise) that saves attachments to disk. You can then call this script from a rule that fires whenever e-mail arrives.

I know this is a bit vague; if you provide more detailed information, it might be possible to give a more specific answer.
Best wishes,
Hans

User avatar
jscher2000
2StarLounger
Posts: 148
Joined: 26 Dec 2010, 18:17

Re: Hypothetical Outlook Question

Post by jscher2000 »

Joseph wrote:Can you use vba to auto save specific files to specific locations once they hit your inbox?
As Hans notes, there is an interface in Outlook to do this. The actual VBA code resides in the local VbaProject.otm file for that installation of Outlook, which raises the question: in the Citrix environment you would retain those external resources between sessions, or only what is in your mailbox?

User avatar
Joseph
3StarLounger
Posts: 206
Joined: 31 Dec 2010, 22:23
Location: Columbia Falls, MT

Re: Hypothetical Outlook Question

Post by Joseph »

I have a lot of people all using a workbook, and they are supposed to save that workbook in their designated folder on the public drive. However, some of the managers are in remote locations and can not access the Citrix server. So, they all email them to me, and I have to save them on the server for them, in their folder. Could someone provide an example in vb, to save email "Report" from "john" to the "I:/Report" folder, then delete the email?

I'm getting killed by these emails and need a solution. Thanks.

User avatar
HansV
Administrator
Posts: 78229
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Hypothetical Outlook Question

Post by HansV »

Do you want to save the e-mail or the attachment?
Best wishes,
Hans

User avatar
Joseph
3StarLounger
Posts: 206
Joined: 31 Dec 2010, 22:23
Location: Columbia Falls, MT

Re: Hypothetical Outlook Question

Post by Joseph »

Very sorry, yes, the attachment. The email subject (if pertinent) is "Report", the attachment is named "Report.xls" for example. The file I:/Report/Report.xls already exists, so it would need to be overwritten on each instance.

User avatar
HansV
Administrator
Posts: 78229
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Hypothetical Outlook Question

Post by HansV »

Start Outlook.
Press Alt+F11.
Select Insert | Module.
Copy the following code into the module, and modify it as needed.

Code: Select all

Sub RemoveAttachment(Item As MailItem)
  Dim att As Attachment
  ' Loop through the attachments
  For Each att In Item.Attachments
    ' Check the file name
    If att.FileName = "Report.xls" Then
      ' Delete file from disk if it exists
      On Error Resume Next
      Kill "I:\Report\Report.xls"
      On Error GoTo 0
      ' Save the attachment
      att.SaveAsFile "I:\Report\Report.xls"
      ' Delete the item
      Item.Delete
      ' Get out
      Exit For
    End If
  Next att
End Sub
Switch back to Outlook.
The following description is for Outlook 2007.
Select Tools | Rules and Alerts...
Click New Rule.
Click 'Check messages when they arrive' under 'Start from a blank rule'.
Click Next >.
Tick the check box "from people or distribution list".
Click the corresponding link in the lower part of the dialog.
Select the sender in the list, or enter the sender's e-mail address in the From box, then click OK.
Tick the check box "with specific words in the subject".
Click the corresponding link in the lower part of the dialog.
Enter the word(s) that characterize the message, e.g. Report, click Add, then click OK.
x491.png
Click Next >.
Tick the check box "run a script".
Click the corresponding link in the lower part of the dialog.
Select Project1.RemoveAttachment (or whatever name you used), then click OK.
Tick the check box "stop processing more rules".
x492.png
Click Next > twice.
Specify a name for the rule.
x493.png
Click Finish.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
Joseph
3StarLounger
Posts: 206
Joined: 31 Dec 2010, 22:23
Location: Columbia Falls, MT

Re: Hypothetical Outlook Question

Post by Joseph »

Good deal, Hans and thanks.

The drive I'm trying to save to, has a very long title. I can't seem to figure out how to get it to save to it.

Here is the full title of it, not sure if I need to specify the whole name or what. I tried a few variations with no luck.

RWS_Ops_Dept$ on 'EMC-SNAS:T5.6.47.11 (rlgdatafs02)'(I:)

Also, does it make any difference if there are spaces in the file name? "The Report.xls" Would I keep those spaces.
Last edited by Joseph on 27 Jan 2011, 12:23, edited 1 time in total.

User avatar
HansV
Administrator
Posts: 78229
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Hypothetical Outlook Question

Post by HansV »

Since the folder has a drive letter I: assigned to it, you can use I:\ instead of the long UNC path.
Best wishes,
Hans

User avatar
Joseph
3StarLounger
Posts: 206
Joined: 31 Dec 2010, 22:23
Location: Columbia Falls, MT

Re: Hypothetical Outlook Question

Post by Joseph »

Oop...got it!!! Thanks Hans!!! I forgot a .xls in there.