Remote File Access Through E-Mail

My Sites: My Blog | My Tech Blog | Follow me on Twitter
—-

download

Download: shantz-outlook-remote-file
Version: 0.1
Updated: April 23, 2008
Size: 1.19 KB
Hits: 906

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.


—-
If you liked this post, then you can Subscribe to my feed
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • blogmarks
  • IndianPad
  • StumbleUpon
  • Technorati
  • Facebook
  • Live
  • Reddit
  • Slashdot
  • YahooMyWeb
  • e-mail

Related posts

29 Responses to “Remote File Access Through E-Mail”

  1. Project: Retrieve Files From Remote Computer Through E-mail | My Technophilic Musings Says:

    [...] Remote File Access Through E-Mail [...]

  2. Rohit Khurana Says:

    fundooo!!!!
    Thats cool !

  3. Shantanu Goel Says:

    thnx rohit :)

  4. Retrieve any file on your home computer by email « Sam’s blog Says:

    [...] Don’t have a Mac, windows users click here for similar [...]

  5. Retrieve Any File on Your Home Computer via Email, Windows Edition [Remote Access] · TechBlogger Says:

    [...] 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 [...]

  6. llcooljayce Says:

    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!

  7. JJMelo Says:

    Awesome. I will use this script to make outlook do other stuff for me.

  8. Shantanu Goel Says:

    @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…

  9. Shantanu Goel Says:

    @JJMelo: thnx. Do send me a word if you do any modifications :)

  10. pradeep kodali Says:

    Really very cool!! Nice job!!

  11. Shantanu Goel Says:

    thnx pradeep :)

  12. Steven Says:

    Or, you could just use this free program…
    http://www.runtime.org/remotebymail.htm

  13. Shantanu Goel Says:

    @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)….

  14. Retrieve Any File on Your Home Computer via Email, Windows Edition « Unleash your inner geek Says:

    [...] 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 [...]

  15. Erich Haubrich » Blog Archive » Retrieve Any File on Your Home Computer via Email, Windows Edition Says:

    [...] [Remote file access through email]  via [Lifehacker] [...]

  16. links for 2008-02-21 at Iain McWhirter Says:

    [...] Remote File Access Through E-Mail (tags: email remote file howto) [...]

  17. baby Says:

    Great website!! Keep up the good work!!

  18. Jack Says:

    cool concept! Could it be re-written to place a file on a computer in a specific folder?

  19. Shantanu Goel Says:

    @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.

  20. Top 10 Email Productivity Boosters [Feature] » Lifehacker, tips and downloads for getting things done Says:

    [...] 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 [...]

  21. Life Clerks » Top 10 Email Productivity Boosters [Feature] Says:

    [...] 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 [...]

  22. Top 10 Email Productivity Boosters at pcnelson.com Says:

    [...] 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 [...]

  23. Top 10 Email Productivity Boosters [Lifehacker Top 10] » Lifehacker, tips and downloads for getting things done Says:

    [...] 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 [...]

  24. Top 10 Email Productivity Boosters [Lifehacker Top 10] · TechBlogger Says:

    [...] 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 [...]

  25. Jason Says:

    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.

  26. Shantanu Goel Says:

    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

  27. arejae Says:

    wow….thanks for the download file. it’s very helpful.

  28. Shantanu Goel Says:

    arejae, glad you liked it. :)

  29. BRAJESH Says:

    i am using and it work nicely.

Leave a Reply