|
-
Jul 28th, 2000, 03:40 AM
#1
Thread Starter
Lively Member
ok, how do i even start????
i would like to send a fax from vb, but first i must
send my data to a word document and then fax it from there?
i tried the sendobject in access to send my report, but
my report format does'nt get faxed. (all the lines and
logos and stuff) and it first asks you for a default user or something like that - how do i answer ok to this from within vb?
any other suggestions would be much appreciated!
maybe right a macro in word that sends out the documents
as soon as it receives it? but what if there's like
3 documents? what about a template?
thanks
Adri
-
Jul 28th, 2000, 05:17 AM
#2
Fax using Outlook
If you have microsoft Outlook on your machine and Microsoft Fax installed it is possible to send a fax using the Outlook object.
You will need to include the following References:
Outlook98 Type Library
Microsoft Office 6.0 Object Library
You can then send a fax using the following functions:
'=========================================================
Function SendFax(Number As String, Document As String, Optional SubjectText As String) As Boolean
' Function to send an attached document as a Fax to Outlook. '
' Specify the fax number and the document to send. '
'NOTE: You must open outlook using the function CALL OUTLOOKOPEN before using sendfax
'When you have finished creating fax documents you should also issue CALL OUTLOOKCLOSE
'to ensure outlook is closed.
Dim Result As String
'Logon process.
Dim MyMail As Outlook.MailItem
Set MyMail = OutLookApp.CreateItem(olMailItem)
MyMail.To = "[FAX: " & gOutsideLine & Number & " ]"
If SubjectText <> "" Then MyMail.Subject = SubjectText
MyMail.Attachments.Add Document
MyMail.Send
SendFax = True
Set MyMail = Nothing
End Function
'=======================================================
'YOU WILL ALSO NEED THE NEXT 2 FUNCTIONS
'=======================================================
Function OutLookOpen() As Boolean
On Error GoTo OpenOutLookErr
'Create a new outlook application
If OutLookApp Is Nothing Then
'Outlook has been closed by the user or has not yet been opened. So outlook must be opened.
Set OutLookApp = CreateObject("Outlook.application")
Set MyNameSpace = OutLookApp.GetNamespace("MAPI")
Set objFolder = MyNameSpace.GetDefaultFolder(olFolderInbox)
objFolder.Display
End if
End Function
Public Function OutlookClose()
On Error Resume Next
'Close Outlook down
OutLookApp.Quit
Set OutLookApp = Nothing
End Function
'=======================================================
Let me know if this helps?
-
Jul 28th, 2000, 05:37 AM
#3
Thread Starter
Lively Member
Hi ChrisLee,
i'm not familiar with Outlook at all, but will
try the code - thanks!
will outlook then send the fax by itself?
Thanks again!
-
Jul 28th, 2000, 05:53 AM
#4
Sending a fax with Outlook
If you look in the code you will notice the line
MyMail.To = "[FAX: " & gOutsideLine & Number & " ]"
It is the prefix "[FAX:
that tells Outlook that this 'E-mail' is actually a fax and that it should contact Microsoft Fax to pass on the message.
Outlook makes no distinction between an E-mail and a Fax they are both the same thing.
The code to send an E-mail would be almost identical except the line 'MyMail.To' would specify an e-mail address.
A few more things I should mention:
(1) You will need to create all of your Word Documents first before you 'attach' them.
If you have multiple word documents to send to different fax machines you should create them all first before using the fax routine.
(2) You can attach just about any form of Office based document by specifying the path of the document when calling the function eg. Word Documents or Excel spreadsheet.
(3) You may need to specify the variable gOutsideLine if you want to specify a outside line prefix.
(4) You should test sending an Outlook Fax before trying to do it automatically using VB.
Create a new E-mail and enter the following in the To box:
[FAX: {yournumberhere} ]
Enter the rest of your information as if you are sending an E-mail
Attach any word documents and click send.
If Microsoft Fax is correctly installed then this should work. Get manual fax working before you try using the code!
Let me know how you get on?
-
Aug 1st, 2000, 08:34 AM
#5
Thread Starter
Lively Member
Hi ChrisLee
Thanks very much for the coding!
It works excellent! (On my machine with Win 95)
But what now if you have to do it on a Windows /98 or NT machine? Do I have to get any other faxing software?
Do you have any other suggestions?
Thanks very much, I learnt a lot from you!
Adri
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|