Fax, email or print

I have a system (Access 97) which is 2 weeks overdue.  The one thing we need is a routine which will, at a particular time, go through a list of company names and either fax, email, or print a report for/to each company.  This needs to be done unattended.

The timing won't be a problem, neither will be the retrieval of the list from the database.  If the program is provided with a desired output mode (say txtOutMode), and a phone number or email address (say txtAddress) as appropriate, how can I do this?  It would be preferable if the coding were done within the database, since that is where the report is being generated.

This one is fascinating, and I wish I had the time to research it myself.  Any help would be appreciated.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

john_priceAuthor Commented:
Edited text of question
john_priceAuthor Commented:
Edited text of question
For FAX and e-mail, look at the MAPI control if you have it?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

john_priceAuthor Commented:
Thanks for the fast reply.  I do have the MAPI controls.  I guess the real problem seems to be how to fax.  My program needs to read the fax phone number and send the fax to that number, without user intervention.  I can't find anything on faxing in the MAPI help.

email is also a little confusing, since I want to email (or fax or print) the output from a report.  How would that be done?

This has got to be a common thing to do.

At this late stage, I am hoping for a code example, say somthing like:

do until Company.eof
... get strDeliveryMode      '  E=email, F=fax, P=Print
                             ' Don't need help here

  Select case strDeliveryMode
     case "P"
        ... print it         ' Don't need help here

     case "E"
        ... get strAddress   ' email address (internet)
                             ' Don't need help on that either

'>>> and here's where I need help:
        ... send report via email
     case "F"
        ... get strAddress   ' fax phone Number
                             ' don't need help here

'>>> also need help here:
        ... send report via fax  ' Must dial phone without
                                 ' without operator intervention
  end select


I think it should all be possible via MAPI if you install the fax service which is used in Windows Messaging. I am not sure if I'll be able to provide you with a MAPI sample quickly enough though, so I won't attempt an answer right now.
Hello John !

I am interested of this code if you can make it work.
I use VB5 and have the MAPI controls.

Janne Sweden

john_priceAuthor Commented:
y96andha -- Its quick enough if it beats any others.  So far, I'm still at the same spot.  Have another project kicking off tomrrow, so there is still no chance for me to dig in.

jannea  -- be my guest.  If we get it working, share away.

-- John
Check out Q145787 and Q125853 in The MS Knowledge Base.  These are not complete solutions, but they'll get you in the ballpark.
john_priceAuthor Commented:
Sorry for the delay getting back.  Had to get the articles, write the code and test.  Got it all working.  Thanks very much.

-- John
john_priceAuthor Commented:
Guess you'll have to answer me so that I can grade the answer.  Thanks again.  The Knowledge base articles led to a line of research.  While one of the articles did not help directly, being for EXCEL, the "see also's" and related topics got me the rest.  I just today provided the working code to the client.

Thanks for your code John !

But i have solve my problem in another way whith MAPI-Calls, Keep in toutch if you are interested.
I´ll  found a book 'MAPI, SAPI & TAPI' by Michael Amundsen, I think its wery good book if you work with this kind off App´s.

Hello John Price!!

Im interested in this code too, i like to know if you can share it with me.
Months ago i asked some question like this and got no response.

10,000 thanks in advance.

john_priceAuthor Commented:
Note to board sysops:  I don't know how to award the points at this point.  I guess Cymbolic deserves the points.  He didn't give me the answer, but pointed me to it, and so probably deserves a c - b grade on the answer?  Thanks.
John, I'll submit this as my answer, but you're right, it sure doesn't deserve a high grade, but this way you can close out the question.  If you have interesting code snippets that you'd like to share, it would be good for others who use the Experts Exchange answers to post them here as comments.  That way when they look up answered questions(this one) they get something for their points.  Congratulations and hang in there!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
john_priceAuthor Commented:
Well, I got my problem solved, and that was the purpose.  High grade or not, I appreciate your response.  It saved me the time spent looking through the kb.  The end result is a kick.  Thanks.

Here is the code for all to share:

Private Sub cmdPrintReports_Click()
    Dim strDBName As String         ' name of database
    Dim rsCreditUnion As Recordset  ' Credit Union table
    Dim strbin As String            ' BIN ID
    Dim strDeliverOption As String  ' "M"=MAil, "E"=Email, "F"=Fax
    Dim strAddress As String        ' email address or fax number
    Dim strReportName As String     ' Name of report
    Dim strWhere As String          ' Where clause
    Dim rptReport As Report         ' Report object being printed
' Open table
    Set rsCreditUnion = CurrentDb.OpenRecordset("tblCreditUnion", dbOpenTable)
    strDBName = CurrentDb.NAME
    strReportName = "rptSummarySheet"
    Do Until rsCreditUnion.EOF
' get credit union information
       strbin = rsCreditUnion("txtBIN")
       strDeliverOption = rsCreditUnion("txtDeliverOption") & ""
       strWhere = "txtBinNumber='" & strbin & "'"

' This report uses a query which is built from the tblHeaders and
' tblHistory tables.
' strWhere is the appropriate "Where" clause for this BIN.
            Select Case UCase(strDeliverOption)
                Case "M"                                                            ‘ Mail (hard copy)
    ' Reference: Q145707
                    If Not OLEOpenReport(strDBName, _
                        strReportName, _
                        acNormal, _
                        , _
                        strWhere) Then
                       '... Log exception to log file
                    End If
                Case "F"                                                            ‘ Fax
    ' Reference: Q145787
                    strAddress = rsCreditUnion("txtAddress")
                    Reports(strReportName).Filter = strWhere
                    DoCmd.SendObject acReport, _
                        strReportName, _
                        acFormatRTF, _
                        "[fax:" & strAddress & "]", , , , , _
                Case "E"                                                            ‘ Email
    ' Reference: Q145787
                    strAddress = rsCreditUnion("txtAddress")
                    DoCmd.OpenReport strReportName, acViewDesign

                    Reports(strReportName).Filter = strWhere
                    DoCmd.Close acReport, strReportName, acSaveYes
                    DoCmd.SendObject acReport, _
                        strReportName, _
                        acFormatRTF, _         ‘<<<<<<< could also use acFormatTXT
                        strAddress, , , , , _
                Case "T"                 ' Text file
' 4th param to .OutputTo - file name of file to create
                    strAddress = rsCreditUnion("txtAddress")
                    DoCmd.OutputTo acOutputReport, _
                        strReportName, _
                        acFormatTXT, _
                        strAddress, _

            End Select
        End If

' Close and release the table
    Set rsCreditUnion = Nothing
End Sub

the function OLEOpenReport is in the referenced article, and I simply copied it and it’s sister function to a new module.  Works neat.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.