Send Faxes via Email Using Outlook

 

My Homemade Email Fax Service

This is a project I was thinking about for a while. I have a great service called Callwave that lets me receive faxes via email, but I cannot send faxes. I looked into several services like eFax, but they were all more expensive than I was willing to pay. I rarely send faxes. I could send faxes from home, but sometimes I needed to fax from work or at Starbucks or something.

 

I wanted to be able to email a file to my home computer and have it send it as a fax automatically. So, I did this project one afternoon.

 

Note: This code allows you to set up an unattended computer to fax email attachments it receives. The script automates keystrokes on the computer in order to send the fax. Therefore, it won’t work well if you or someone else is currently using the computer when the script runs. So, send the email from a different computer than the one set up to send faxes.

 

System Requirements

 

Set-up Instructions

 

 Sending a Fax via Email

  1. Create an email message and type “FAX” and then the recipient’s phone numbering the subject line. (Ex. FAX 2145551212)
    Don’t use spaces in the phone number and make sure it’s the last thing in the subject line.
  2. Attach a document to the email.
  3. Send the email.
    If you have set up the recipient computer correctly, it should receive the email and fax the attachment to the number in the subject line.

 

Outlook Script Code

Here is the code for the outlook script. A couple things to note:

 

Private Declare Function ShellExecuteA Lib "Shell32" (ByVal hwnd As Integer, ByVal lpOperation As String, ByVal lpFile As String, lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Integer) As Integer
 
 
Sub CustomMailMessageRule(Item As Outlook.MailItem)
 
    '******** Written 07/28/2005 
    '******** This Outlook script will fax an email attachment to the phone # in the subject line
    '******** This code is provided As-Is with no warranty expressed or implied.
 
    If Item.Attachments.Count = 0 Then Exit Sub     ' stop if there are no attachments
    Dim sPath As String
 
    sPath = "C:\faxtemp\" + Item.Attachments.Item(1).FileName
    Item.Attachments.Item(1).SaveAsFile (sPath)     'save attachment to C:\faxtemp
    Dim RetVal
    RetVal = ShellExecuteA(0, "print", """" + sPath + """", vbNullString, vbNullString, 0)
    
    '******** Wait for 10 seconds so the Fax Wizard dialog has time to appear ********'
    
    PauseTime = 10                                  ' Set duration.
    Start = Timer                                   ' Set start time.
    Do While Timer < Start + PauseTime
        DoEvents                                    ' Yield to other processes.
    Loop
    Finish = Timer
    
    SendKeys "{ENTER}", True                        'Press ENTER to go to next screen on Fax Wizard
  
    PauseTime = 2
    Start = Timer
    Do While Timer < Start + PauseTime
       DoEvents
    Loop
    Finish = Timer
 
   SendKeys Right$(Item.Subject, 10), True          'Enter last 10 characters of subject as recipient
   SendKeys "{TAB}" & "{TAB}", True                 'Press TAB to skip to the correct box on dialog
   SendKeys Right$(Item.Subject, 10), True          'Enter last 10 characters of subject as phone
 
   PauseTime = 1
   Start = Timer
   Do While Timer < Start + PauseTime
       DoEvents
   Loop
   Finish = Timer
 
   SendKeys "{ENTER}", True                         'Press ENTER to go to next screen
    PauseTime = 1
    Start = Timer
    Do While Timer < Start + PauseTime
       DoEvents
    Loop
    Finish = Timer
 
   SendKeys "{ENTER}", True                         'Press ENTER to go to next screen
    PauseTime = 1
    Start = Timer
    Do While Timer < Start + PauseTime
       DoEvents
    Loop
    Finish = Timer
 
   SendKeys "{ENTER}", True                         'Press ENTER to go to next screen
    PauseTime = 1
    Start = Timer
    Do While Timer < Start + PauseTime
       DoEvents
    Loop
    Finish = Timer
 
   SendKeys "{ENTER}", True                         'Press ENTER to Finish
 
   
End Sub 

 

 

 

Other Links

If you need your taxes prepared professionally, check out www.stonebridgetax.com.