Sending fax from VBA

J

John Galt

Does anyone have working code to send a fax from VBA using Outlook.Mailitem?
I have tried some examples I have found and they all simply try to use the
Fax number as an e-mail address.

Thanks in advance
 
S

Sue Mosher [MVP]

That's the standard, generic method unless you are using fax software that
has its own API.
 
J

John Galt

Sue here is the code I have. Do you see any issues with it?


Private Sub cmdSendFax_Click()
Dim objOutlook As New Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim TelNo As String

TelNo = "18887498870" '

'Create a mail item.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.To = "[Fax: " & TelNo & "]"
.Subject = "SUBJECT LINE GOES HERE"
.Body = "To Mr. XYZ" & Char(10) & " This is an Automated
Transmission from the computer." & Char(10) & "Send Fax Completed." &
Char(10) & "------ End of Doc ------"
.Importance = olImportanceHigh
.Attachments.Add ("C:\windows\win.ini") 'Pathname+filename with ext
.Send
End With
Set objOutlookMsg = Nothing

End Sub
 
S

Sue Mosher [MVP]

Looks fine, assuming that you have a fax component in the current Outlook
setup that supports the standard [FAX:number] syntax. You never said what
fax software you're using.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



John Galt said:
Sue here is the code I have. Do you see any issues with it?


Private Sub cmdSendFax_Click()
Dim objOutlook As New Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim TelNo As String

TelNo = "18887498870" '

'Create a mail item.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.To = "[Fax: " & TelNo & "]"
.Subject = "SUBJECT LINE GOES HERE"
.Body = "To Mr. XYZ" & Char(10) & " This is an Automated
Transmission from the computer." & Char(10) & "Send Fax Completed." &
Char(10) & "------ End of Doc ------"
.Importance = olImportanceHigh
.Attachments.Add ("C:\windows\win.ini") 'Pathname+filename with ext
.Send
End With
Set objOutlookMsg = Nothing

End Sub


Sue Mosher said:
That's the standard, generic method unless you are using fax software that
has its own API.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
J

John Galt

I am using the microsoft fax that comes with Outlook or XP.
I can print to the fax from other applications but the " .to = FAX: etc..."
only treats the phone number as an e-mail address.



Sue Mosher said:
Looks fine, assuming that you have a fax component in the current Outlook
setup that supports the standard [FAX:number] syntax. You never said what
fax software you're using.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



John Galt said:
Sue here is the code I have. Do you see any issues with it?


Private Sub cmdSendFax_Click()
Dim objOutlook As New Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim TelNo As String

TelNo = "18887498870" '

'Create a mail item.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.To = "[Fax: " & TelNo & "]"
.Subject = "SUBJECT LINE GOES HERE"
.Body = "To Mr. XYZ" & Char(10) & " This is an Automated
Transmission from the computer." & Char(10) & "Send Fax Completed." &
Char(10) & "------ End of Doc ------"
.Importance = olImportanceHigh
.Attachments.Add ("C:\windows\win.ini") 'Pathname+filename with ext
.Send
End With
Set objOutlookMsg = Nothing

End Sub


Sue Mosher said:
That's the standard, generic method unless you are using fax software that
has its own API.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Does anyone have working code to send a fax from VBA using
Outlook.Mailitem?
I have tried some examples I have found and they all simply try to
use
the
Fax number as an e-mail address.

Thanks in advance
 
S

Sue Mosher [MVP]

Since Outlook 2002 doesn't include any fax component, I'm not sure what
you're referring to.

Printing to a fax printer doesn't count. The component has to be able to
send to a fax recipient.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



John Galt said:
I am using the microsoft fax that comes with Outlook or XP.
I can print to the fax from other applications but the " .to = FAX: etc..."
only treats the phone number as an e-mail address.

Sue Mosher said:
Looks fine, assuming that you have a fax component in the current Outlook
setup that supports the standard [FAX:number] syntax. You never said what
fax software you're using.

John Galt said:
Sue here is the code I have. Do you see any issues with it?


Private Sub cmdSendFax_Click()
Dim objOutlook As New Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim TelNo As String

TelNo = "18887498870" '

'Create a mail item.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.To = "[Fax: " & TelNo & "]"
.Subject = "SUBJECT LINE GOES HERE"
.Body = "To Mr. XYZ" & Char(10) & " This is an Automated
Transmission from the computer." & Char(10) & "Send Fax Completed." &
Char(10) & "------ End of Doc ------"
.Importance = olImportanceHigh
.Attachments.Add ("C:\windows\win.ini") 'Pathname+filename
with
ext
.Send
End With
Set objOutlookMsg = Nothing

End Sub


That's the standard, generic method unless you are using fax
software
that
has its own API.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Does anyone have working code to send a fax from VBA using
Outlook.Mailitem?
I have tried some examples I have found and they all simply try to use
the
Fax number as an e-mail address.

Thanks in advance
 
J

John Galt

The Fax component is the Fax Mail Transport.
I set it up as an e-mail account in Outlook.

I eventually did figure it out. The problem is that the fax number MUST be
in the format +1 (555) 555-1212 (with spaces dashes and parens). The
outlook will not invoke the fax transport w/o the number being precisely
formatted. (Pretty poor design but...)



Sue Mosher said:
Since Outlook 2002 doesn't include any fax component, I'm not sure what
you're referring to.

Printing to a fax printer doesn't count. The component has to be able to
send to a fax recipient.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



John Galt said:
I am using the microsoft fax that comes with Outlook or XP.
I can print to the fax from other applications but the " .to = FAX: etc..."
only treats the phone number as an e-mail address.

Sue Mosher said:
Looks fine, assuming that you have a fax component in the current Outlook
setup that supports the standard [FAX:number] syntax. You never said what
fax software you're using.

Sue here is the code I have. Do you see any issues with it?


Private Sub cmdSendFax_Click()
Dim objOutlook As New Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim TelNo As String

TelNo = "18887498870" '

'Create a mail item.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.To = "[Fax: " & TelNo & "]"
.Subject = "SUBJECT LINE GOES HERE"
.Body = "To Mr. XYZ" & Char(10) & " This is an Automated
Transmission from the computer." & Char(10) & "Send Fax Completed." &
Char(10) & "------ End of Doc ------"
.Importance = olImportanceHigh
.Attachments.Add ("C:\windows\win.ini") 'Pathname+filename with
ext
.Send
End With
Set objOutlookMsg = Nothing

End Sub


That's the standard, generic method unless you are using fax software
that
has its own API.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Does anyone have working code to send a fax from VBA using
Outlook.Mailitem?
I have tried some examples I have found and they all simply try
to
use
the
Fax number as an e-mail address.

Thanks in advance
 
S

Sue Mosher [MVP]

"Fax Mail Transport" doesn't tell us much, does it? Maybe it's the WinFax SE
component? Maybe it's the Windows XP component? I sure don't know from the
name.

Anyway, most fax components need the number to be in good canonical format
in order to know how to apply the Windows dialing rules. But your mileage
may vary with different components.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



John Galt said:
The Fax component is the Fax Mail Transport.
I set it up as an e-mail account in Outlook.

I eventually did figure it out. The problem is that the fax number MUST be
in the format +1 (555) 555-1212 (with spaces dashes and parens). The
outlook will not invoke the fax transport w/o the number being precisely
formatted. (Pretty poor design but...)



Sue Mosher said:
Since Outlook 2002 doesn't include any fax component, I'm not sure what
you're referring to.

Printing to a fax printer doesn't count. The component has to be able to
send to a fax recipient.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



John Galt said:
I am using the microsoft fax that comes with Outlook or XP.
I can print to the fax from other applications but the " .to = FAX: etc..."
only treats the phone number as an e-mail address.

Looks fine, assuming that you have a fax component in the current Outlook
setup that supports the standard [FAX:number] syntax. You never said what
fax software you're using.

Sue here is the code I have. Do you see any issues with it?


Private Sub cmdSendFax_Click()
Dim objOutlook As New Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim TelNo As String

TelNo = "18887498870" '

'Create a mail item.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.To = "[Fax: " & TelNo & "]"
.Subject = "SUBJECT LINE GOES HERE"
.Body = "To Mr. XYZ" & Char(10) & " This is an Automated
Transmission from the computer." & Char(10) & "Send Fax
Completed."
try
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top