Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows
Visual Basic > Internet Web Mail Stuff sample source codes
Send a fax using Microsoft Outlook
Send a fax using Microsoft Outlook The following code demostrates how to send a fax using Microsoft Outlook. 'Purpose : Sends a fax using Outlook and Microsoft Fax 'Inputs : sFaxNumber The fax number to send the fax to. ' sSubject The fax subject. ' sBody The fax body. ' [sFileName] The file to fax. 'Outputs : Returns an empty string on success, else returns an error description 'Notes : Will return a "System Adminstrator" undeliverable message if you do not have ' Microsoft Fax installed. Function OutlookSendFax(sFaxNumber As String, sSubject As String, sBody As String, Optional sFileName As String) As String Dim oOutlook As Object 'Outlook.Application Dim oFax As Object 'Outlook.MailItem On Error GoTo ErrFailed Set oOutlook = CreateObject("Outlook.Application") Set oFax = oOutlook.CreateItem(0) 'olMailItem With oFax .To = "[Fax:" & sFaxNumber & "]" .Subject = sSubject .Body = sBody If Len(sFileName) Then If Len(Dir$(sFileName)) Then 'Add attachment .Attachments.Add sFileName End If End If .Send End With Set oFax = Nothing Set oOutlook = Nothing OutlookSendFax = "" 'Return success Exit Function ErrFailed: 'Failed, return error description OutlookSendFax = "Error in OutlookSendFax: " & Err.Description End Function 'Demonstration routine Sub Test() OutlookSendFax "020 7773 1994", "TEST SUBJECT", "TEST BODY", "c:\myfile.doc" End Sub
Privacy Policy
|
Link to Us
|
Links