Introduction:
This is a (proof-of-concept) outlook macro that you can use with an outlook rule to retrieve your files from your home/office PC by sending it a mail with a subject having a predefined special keyword and the body containing the names and paths of the files. The remote PC will then mail you the files on a predefined e-mail ID.
This project came into being after reading this post at lifehacker (original post and solution here). It listed a method to retrieve mails on your home/office PC by sending a “magic email” to it, but it was only for mac’s. Seeing that people wanted it for windows as well, I thought of making something up during lunch time at office.
Usage:
1. Download the attached zip file (shantz-outlook-remote-file-access.zip) and unzip it. It has a VB module “shantz-outlook-remote-file-access.bas” (can be opened with any text editor)
2. Create a new macro in Outlook. Copy the code contained in Module1.bas to the main source file of the macro.
3. Edit the code to change the e-mail ID to which the files will be e-mailed. Save the macro.
4. Create a new rule in Outlook. Choose to run the rule when a specific word is found in the subject. e.g. use “SendMeMyFiles”.
5. The action part of the rule should be “run a script”. Here you can choose the macro that you just created from the list shown by Outlook.
6. Save the rule and you are done.
Now try, sending a mail to the account that your outlook is configured to receive mail for, with the special keyword in the subject and a list of files (with their complete absolute paths on the remote computer) separated by semicolons (“;” without the quotes), and watch magic happen
.
e.g.: To: myemail@email.com
subject: SendMeMyFiles
Body: c:\path\of\files\file1;d:\second\path\file2
IMPORTANT NOTES:
- For this thing to work, outlook has to be running on the remote PC as this depends on a “client-side” rule.
- This is just a proof-of-concept as of now, so there is no error handling right now. Plus the e-mail body parsing is finicky and so the e-mail body should not have anything other than the file paths and names. This might change in future if I decide to update it.
- Don’t use it if your life depends on it. Use it for basic purposes and modify and improve it appropriately before you decide to use it seriously (You may submit your modifications here as well)
- It has been tested only on Outlook 2003, but might work on others as well.
Let me know of any thoughts you may have about this.



[...] Remote File Access Through E-Mail [...]
fundooo!!!!
Thats cool !
thnx rohit
[...] Don’t have a Mac, windows users click here for similar [...]
[...] great way to retrieve the file you forgot, and you can retrieve it anywhere you have email access. Remote File Access Through E-Mail [My Technophilic Musings via [...]
When you set up the macro in Outlook, I’m assuming you set up a new macro name, I used ‘remote’
So then you you hit create and you get the following code:
Sub remote()
End Sub
Are you supposed to paste your code in between the sub and end sub? Like so:
Sub remote()
Attribute VB_Name = “Module1″
Function mail(strTo As String, _
strSubject As String, _
strMessageBody As String, _
Optional strAttachments As String) As Boolean
Dim MAPISession As Outlook.NameSpace
Dim MAPIFolder As Outlook.MAPIFolder
Dim MAPIMailItem As Outlook.MailItem
Dim oRecipient As Outlook.Recipient
Dim TempArray() As String
Dim varArrayItem As Variant
Dim blnSuccessful As Boolean
Set MAPISession = Application.Session
If Not MAPISession Is Nothing Then
MAPISession.Logon , , True, False
Set MAPIFolder = MAPISession.GetDefaultFolder(olFolderOutbox)
If Not MAPIFolder Is Nothing Then
Set MAPIMailItem = MAPIFolder.Items.Add(olMailItem)
If Not MAPIMailItem Is Nothing Then
With MAPIMailItem
TempArray = Split(strTo, “;”)
For Each varArrayItem In TempArray
Set oRecipient = .Recipients.Add(CStr(Trim(varArrayItem)))
oRecipient.Type = olTo
Set oRecipient = Nothing
Next varArrayItem
.Subject = strSubject
If StrComp(Left(strMessageBody, 6), “”, vbTextCompare) = 0 Then
.HTMLBody = strMessageBody
Else
.Body = strMessageBody
End If
TempArray = Split(strAttachments, “;”)
For Each varArrayItem In TempArray
varArrayItem = CStr(moreTrim(varArrayItem))
.Attachments.Add varArrayItem
Next varArrayItem
.Send
Set MAPIMailItem = Nothing
End With
End If
Set MAPIFolder = Nothing
End If
MAPISession.Logoff
End If
blnSuccessful = True
End Function
Public Function moreTrim(ByVal sValue As String) As _
String
Dim sAns As String
Dim sWkg As String
Dim sChar As String
Dim lLen As Long
Dim lCtr As Long
sAns = sValue
lLen = Len(sValue)
If lLen > 0 Then
For lCtr = 1 To lLen
sChar = Mid(sAns, lCtr, 1)
If Asc(sChar) > 32 Then Exit For
Next
sAns = Mid(sAns, lCtr)
lLen = Len(sAns)
If lLen > 0 Then
For lCtr = lLen To 1 Step -1
sChar = Mid(sAns, lCtr, 1)
If Asc(sChar) > 32 Then Exit For
Next
End If
sAns = Left$(sAns, lCtr)
End If
moreTrim = sAns
End Function
Sub intercept(MyMail As MailItem)
Dim strID As String
Dim objNS As Outlook.NameSpace
Dim objMail As Outlook.MailItem
Dim replyto As String
Dim result As Boolean
Dim file As String
strID = MyMail.EntryID
Set objNS = Application.GetNamespace(“MAPI”)
Set objMail = objNS.GetItemFromID(strID)
file = objMail.Body
result = mail(“abc@abc.com”, file, “”, file)
End Sub
End Sub
?????
If so, there are syntax errors when I try and call the macro … please help!
Awesome. I will use this script to make outlook do other stuff for me.
@llcooljayce:
You need to “replace” the default code that is present by the source code that I just gave. (Remove the top line which says Module “shantz-….”). Otherwise, you can delete the default file that is there and import the file that I gave…
@JJMelo: thnx. Do send me a word if you do any modifications
Really very cool!! Nice job!!
thnx pradeep
Or, you could just use this free program…
http://www.runtime.org/remotebymail.htm
@Steven: yeah, the solution is just one amongst the sea of others available
, some might find it useful because they can’t use other methods because of restrictions (e.g. installing new softwares)….
[...] way to retrieve the file you forgot, and you can retrieve it anywhere you have email access.” Remote File Access Through E-Mail [My Technophilic Musings via [...]
[...] [Remote file access through email] via [Lifehacker] [...]
[...] Remote File Access Through E-Mail (tags: email remote file howto) [...]
Great website!! Keep up the good work!!
cool concept! Could it be re-written to place a file on a computer in a specific folder?
@jack, yes, it can be rewritten for that..infact it can be modified to do a lot of things, like even shutting down/restarting your computer, running external programs, even modifying files, and what not. Only limitations are:1. How far can you imagine
2. How much you know (or are willing to learn) about outlook macro scripting.
[...] just a neat way to grab a file. Using a keyword and a filename, you can set up Mail.app on Macs or Outlook on PCs to send you your files. If nothing else, you might convince your co-workers that you have magic [...]
[...] just a neat way to grab a file. Using a keyword and a filename, you can set up Mail.app on Macs or Outlook on PCs to send you your files. If nothing else, you might convince your co-workers that you have magic [...]
[...] just a neat way to grab a file. Using a keyword and a filename, you can set up Mail.app on Macs or Outlook on PCs to send you your files. If nothing else, you might convince your co-workers that you have magic [...]
[...] just a neat way to grab a file. Using a keyword and a filename, you can set up Mail.app on Macs or Outlook on PCs to send you your files. If nothing else, you might convince your co-workers that you have magic [...]
[...] just a neat way to grab a file. Using a keyword and a filename, you can set up Mail.app on Macs or Outlook on PCs to send you your files. If nothing else, you might convince your co-workers that you have magic [...]
Great idea. Problem is I would rarely remember the full path of the file.
I think this could be enhanced by asking for a text file oitlining the folder structure first.
For example:
Subject: MailFolderList
C:\ProjectFolder
The result would be a .txt file with all folders and files in it. Then you could execute the retrieve file email.
Yes Jason, you are absolutely right about that. This is just a proof of concept. Basically how I would build on it is that the subject would always remain the same, but the body can contain “commands” followed by arguments and may even contain multiple commands. So u can say smthing like:
shell:dir >c:\files.txt
mailback: c:\files.txt
wow….thanks for the download file. it’s very helpful.
arejae, glad you liked it.
i am using and it work nicely.
[...] and with spotty VPN access, I can’t always get my files. I installed the macro, found at My Technophilic Musings, and immediately set out to make it do [...]
[...] Remote File Access Through E-Mail [...]
I’ve done something similar, but instead,I’ve only used the subject line. I had a ruby script that the macro would call and send it the subject line, so the only work the macro did was to determine if it was the “magic’. This was denoted by the subject line starting with spawn task:xxxxxxx, replyemailaddress. Where xxxxx was one of the verbs that the ruby script expected. The ruby script would perfomr the task and email the result. Tasks were reports on status of certain systems. (dbase up, stage, test environments up, restart stage, test environments). Unfortunatlly MS did not allow for reading the senders email, that way I could respond to the sender, hence the replyemail param. the ruby script would only reply if the domain was one of the allowed few.
i use 2 resive my all e-mail on outlook at my desktop . one day i have use control Import/Export by this my all inbox mail have delete from from my mail id on Net . but it is present on my Desktop in outlook.
so plz tell me how can i send my mail 2 agian at my mail on Enternet
plz help me out before i formate my system.
one more thing i copy outlook folder in other plase but it is not opening . so also tell me how can i open that outlook file ????
plz send me all mail about this prob on drsharmamahesh@rediffmail.com
can i use the script for downloading file from the internet via e-mail?
because in my office, i cant download file bigger than 2 MB via browser or download manager. But if the file is an attachment in e-mail, i can download it.
[...] just a neat way to grab a file. Using a keyword and a filename, you can set up Mail.app on Macs or Outlook on PCs to send you your files. If nothing else, you might convince your co-workers that you have magic [...]
I really enjoyed this blog.,Rachael
Hey good concept.
But Notepad or wordpad cannot read file correctly. It’s giving any bug text.
Please help me out. I need this facility.
Thanks Shantanu for this…You originally wrote it in Feb 2008, now it is more than 3 years.
I would like to try this out….
Please advise if there is any update/ improvement in this. I have outlook in my office, but at home I am not using any email client.
Rgds
I invite you to try ControlByMail (vic2pc.com), which doesn’t need Outlook to remotely control or access your PC: just an email from any email-enabled device (iPhone, PC, Mac, Linux, Android, etc). Thank you.