[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 524
  • Last Modified:

Need VBA Code to send a single FAX to multiple recipients

I'm wondering if there is a way in VBA to send a single fax to a string of fax numbers - as opposed to looping and sending multiple faxes out. I can't seem to get the syntax to work. Any ideas?
0
Eileen Murphy
Asked:
Eileen Murphy
  • 8
  • 5
1 Solution
 
Eileen MurphyIndependent Application DeveloperAuthor Commented:
I just tested this further and if I don't use the .SEND command and rather use the .DISPLAY - then when I click in the Bcc line where the string of phone numbers (I pass from VBA) is displayed, the phone numbers get underlined and seem to be accepted as legitimate phone numbers. If I don't click in the Bcc line and the phone numbers don't get underlined, I get the same error as before: "Outlook does not recognize one or more names..."
Below is my code:

Public Function SendFaxesTEST()
On Error GoTo err_SendFaxesTEST
Err.Number = 0
Dim x

Dim olNs As Outlook.NameSpace
Dim theReport As String, theMsg As String
Dim olapp As New Outlook.Application
Dim olappMsg As Outlook.MailItem
Dim FaxNo As String, FaxTo As String, TheJob As String, TheDate As String, TheTime As String, BidsDueDate As Date, BidsDueTime As String, FromCo As String, theFax As String
Dim SendBidsTo As String, CoFax As String, FaxMemo As String, SentBy As String, InviteDate As Date, FaxString As String, z As String
Dim db As DAO.Database
Dim maillist As DAO.Recordset
Set olNs = olapp.GetNamespace("MAPI")
olNs.Logon
   
Set db = CurrentDb()
Set maillist = db.OpenRecordset("qryFaxRecipients") 'based on tempRecipients table...
   
    Do Until maillist.EOF
   
        FaxNo = "1" & maillist("FaxNumber")
        FromCo = maillist("CompanyName")
        FaxTo = maillist("Company") & " - " & maillist("ContactPerson")
        FaxString = FaxNo & ";" & FaxString            
       
    maillist.MoveNext
    Loop
       
    z = Len(FaxString) - 1
    FaxString = Left(FaxString, z) 'strip the last semi-colon
       
    TheJob = Forms!BidMaster!JobName & " " & Nz(Forms!BidMaster!EstDescription)
    InviteDate = Forms!BidMaster!JobSiteMeetingInviteDate
    TheDate = Nz(Forms!BidMaster!JobSiteMeetingDate, "T.B.D.")
    TheTime = Nz(Forms!BidMaster!JobSiteMeetingTime, "")
    BidsDueDate = Forms!BidMaster!BidDueFromSubsDate
    BidsDueTime = Forms!BidMaster!BidDueFromSubsTime
    SendBidsTo = Nz(DLookup("BidContact", "Companies", "CompanyID" = Forms!switchboard!coAccess), "")
    theFax = Nz(DLookup("CompanyFax", "Companies", "CompanyID" = Forms!switchboard!coAccess), "")
    CoFax = Left(theFax, 3) & "-" & Mid(theFax, 4, 3) & "-" & Right(theFax, 4)
       
    If FaxString <> "1" Then
        Set olappMsg = olapp.CreateItem(olMailItem)
        With olappMsg
            .BCC = FaxString
            .Subject = "REMINDER TO BID JOB"
            .Body = "To: " & FaxTo & Chr(10) & Chr(10) & "From: " & FromCo & Chr(10) & Chr(10) & "RE: On " & InviteDate & " you were invited to and AGREED to Submit a Bid for Project Name: " & TheJob & Chr(10) & Chr(10) & "Bids are Due: " & BidsDueDate & " at: " & BidsDueTime & "." & Chr(10) & Chr(10) & "Send Bids to: " & SendBidsTo & "  or Fax to: " & CoFax & Chr(10) & Chr(10) & UCase(FaxMemo) & Chr(10) & Chr(10) & "PLEASE SUBMIT YOUR BID BY " & BidsDueDate & "." & Chr(10) & Chr(10) & "Thanks " & SendBidsTo
            .Importance = olImportanceHigh
            .Display
        End With
    End If
           
exit_SendFaxesTEST:
   
    Set olappMsg = Nothing
    Set maillist = Nothing
    db.Close
    Set db = Nothing
   
    If Err.Number = 0 Then Exit Function
err_SendFaxesTEST:
    MsgBox "Error " & Err.Number & vbCrLf & Err.Description
    Resume exit_SendFaxesTEST

End Function

OutlookFax.pdf
0
 
Eileen MurphyIndependent Application DeveloperAuthor Commented:
The previous question was also mine - however, this is a different issue. I attached a .pdf with screen shots of what I'm referring to here. Any help would be appreciated!
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
GRayLCommented:
I know that - most viewers coming to this thread won't - that's why I posted it.
0
 
Eileen MurphyIndependent Application DeveloperAuthor Commented:
I see. Okay.
0
 
GRayLCommented:
What about:

           .Importance = olImportanceHigh
           .BCC.setfocus '<-  doing something here equivalent to a click?? - before or after .Display??
           .Display
       End With
0
 
Eileen MurphyIndependent Application DeveloperAuthor Commented:
Nope :(
"Invalid Qualifer" error message - both before and after .Display.
Good thinking though..
 
0
 
Eileen MurphyIndependent Application DeveloperAuthor Commented:
I did some more research and it appears that the fax number is not being "resolved" by Outlook - it's a term that appears to be farely common. One way around it is to add the fax number to the Contacts table and force it to be "resolved" - not a good solution for me.
Any ideas out there?
 
0
 
GRayLCommented:
I'm sorry I do not used Outlook to send FAXes, so I'm up a blind alley.  As to 'resolving' I do not believe you need a contact to be in the Contacts list for that contact to be in BCC.  However, this FAX component may change a few of the rules.  It just may be worth adding a new folder FaxNumbers to the Contacts folder and add them all at one shot.  I imagine just two fields are all that's required, the number and a name.
0
 
Eileen MurphyIndependent Application DeveloperAuthor Commented:
I am going to test sending a string like: "[Fax: ##########]";"Fax:##########]"; etc. I think that may force Outlook to resolve the number... will keep you posted.
0
 
Eileen MurphyIndependent Application DeveloperAuthor Commented:
"[Fax: ##########]";"[Fax:##########]"; "[Fax: ##########]";"[Fax:##########]";
is the solution - substitute the string of # with the phone numbers and it works just dandy.
0
 
GRayLCommented:
Great, award yourself the points as you seem to have found the answer.  Good to know!
0
 
Eileen MurphyIndependent Application DeveloperAuthor Commented:
:) Thank you, as always, for your help. I hope this helps someone in the future. I LOVE THIS SITE!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now