Click here to Skip to main content
15,887,272 members
Articles / Programming Languages / C#
Tip/Trick

Faxing with XP and C#

Rate me:
Please Sign up or sign in to vote.
2.42/5 (30 votes)
5 Jan 2014CPOL 282K   10.4K   49   54
Send faxes with C# using Win 2k or XP

Sample Image - Fax-XP-ing.gif

Introduction

This code can be used to send Faxes using Windows XP and 2000. I have included a bitmap image in the demo that will be faxed to a recipient. You can make your own bitmap using System.Drawing class, save it to disk and then reference it and send it to a fax number. All you need is a Modem, windows fax service which comes with XP and a telephone line and you are on you way. I understand that there might be some issues with limited User rights but have not yet tested it, I was only using my Administator Account when testing this. Anyway, all you might need to do is add a reference to the "faxcom 1.0 Libary" and you are set. Your feed back is welcome and I will keep track on any problems. 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Being IT Solutions
South Africa South Africa
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionin win 8 Pin
Angela 1029384829-Dec-13 19:26
Angela 1029384829-Dec-13 19:26 
GeneralMy vote of 4 Pin
William Croft24-Feb-11 11:05
William Croft24-Feb-11 11:05 
GeneralMy vote of 1 Pin
Shute31230-Aug-09 17:47
Shute31230-Aug-09 17:47 
QuestionFax Application in Windows server 2003 and 2008.. this one is just in xp and 2k rite?? Pin
Amitsglja3-Aug-09 23:51
Amitsglja3-Aug-09 23:51 
QuestionIs there license issue? Pin
san_geit3-Jul-09 0:04
san_geit3-Jul-09 0:04 
QuestionHow can we send a multipage tiff file? Pin
samwiz25-Apr-09 18:12
samwiz25-Apr-09 18:12 
AnswerRe: How can we send a multipage tiff file? Pin
Leon van Wyk30-Apr-09 8:06
professionalLeon van Wyk30-Apr-09 8:06 
QuestionException from HRESULT:0x8007000D Pin
SedArash10-May-08 20:52
SedArash10-May-08 20:52 
Hello,
I try to get the code below to work.
If I use test.tif it works just fine but all other extensions (pdf, txt, jpg
and so on) failing with "The data is invalid Exception from HRESULT:
0x8007000D".

I checked if the default setting for the extensions are correct and they are
assigned to notepad (txt) and acrobat reader (pdf) and Windows Picture and
Fax Viewer for (jpg).
I run Filemon and Regmon to see if there is an permission problem during the
click event but everything seems fine.
After the Error I have 2 events in my server logs.
Event ID 11
Document 4, 1C8673290FA2F - Notepad owned by NETWORK SERVICE was paused on
Fax.
Event ID 13
Document 4, 1C8673290FA2F - Notepad owned by NETWORK SERVICE was deleted on
Fax.


any suggestions what's wrong?


Regards
Anthony


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)


Try
Dim faxserver As FAXCOMLib.FaxServer
Dim faxdoc As FAXCOMLib.FaxDoc


faxserver = New FAXCOMLib.FaxServerClass
faxserver.Connect("")
faxdoc =
faxserver.CreateDocument("c:\inetpub\collecta\temp\test.tif") 'if ichange
the file to test.tif it works


faxdoc.RecipientName = "receiver"
faxdoc.FaxNumber = "2106741826"
faxdoc.DisplayName = "test"
faxdoc.Send()


faxserver.Disconnect()


Catch ex As Exception
Response.Write(ex.Message)
End Try


Error:
The data is invalid. (Exception from HRESULT: 0x8007000D)
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.


Exception Details: System.Runtime.InteropServices.COMException: The data is
invalid. (Exception from HRESULT: 0x8007000D)


Source Error:


Line 41: faxdoc.FaxNumber = "2106741826"
Line 42: faxdoc.DisplayName = "test"
Line 43: faxdoc.Send() (here the error occours)
Line 44:
Line 45: faxserver.Disconnect()


Source File: C:\Inetpub\collecta\Default.aspx.vb Line: 43


Stack Trace:


[COMException (0x8007000d): The data is invalid. (Exception from HRESULT:
0x8007000D)]
FAXCOMLib.IFaxDoc.Send() +0
collecta_Default.Button1_Click(Object sender, EventArgs e) in
C:\Inetpub\collecta\Default.aspx.vb:43
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
+107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaiseP­ostBackEvent(String
eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

Don't Worry ! Be Happy !
SedArash

AnswerRe: Exception from HRESULT:0x8007000D Pin
Leon van Wyk10-May-08 23:53
professionalLeon van Wyk10-May-08 23:53 
GeneralRe: Exception from HRESULT:0x8007000D Pin
SedArash11-May-08 1:23
SedArash11-May-08 1:23 
GeneralRe: Exception from HRESULT:0x8007000D Pin
sSupergirl15-Aug-08 4:17
sSupergirl15-Aug-08 4:17 
GeneralRe: Exception from HRESULT:0x8007000D Pin
Leon van Wyk15-Aug-08 4:31
professionalLeon van Wyk15-Aug-08 4:31 
GeneralRe: Exception from HRESULT:0x8007000D Pin
sSupergirl15-Aug-08 5:03
sSupergirl15-Aug-08 5:03 
GeneralRe: Exception from HRESULT:0x8007000D Pin
qiusongze5-Oct-08 23:40
qiusongze5-Oct-08 23:40 
GeneralThe system can not find the file specified Pin
Zapss27-Jan-08 20:36
Zapss27-Jan-08 20:36 
GeneralFile Name + Fax Information Pin
s3rro25-Sep-07 4:16
s3rro25-Sep-07 4:16 
GeneralRe: File Name + Fax Information Pin
Leon van Wyk25-Sep-07 6:26
professionalLeon van Wyk25-Sep-07 6:26 
GeneralRe: File Name + Fax Information Pin
s3rro26-Sep-07 3:54
s3rro26-Sep-07 3:54 
GeneralUnknown Exceptional error Pin
mast42823-Jul-07 2:51
mast42823-Jul-07 2:51 
GeneralRe: Unknown Exceptional error Pin
mast42823-Jul-07 3:30
mast42823-Jul-07 3:30 
GeneralProblem accessing FAXCOM from other service Pin
LAcike@sk28-Jun-07 5:20
LAcike@sk28-Jun-07 5:20 
GeneralRe: Problem accessing FAXCOM from other service Pin
Leon van Wyk28-Jun-07 9:19
professionalLeon van Wyk28-Jun-07 9:19 
GeneralRe: Problem accessing FAXCOM from other service Pin
LAcike@sk28-Jun-07 22:28
LAcike@sk28-Jun-07 22:28 
GeneralRe: Problem accessing FAXCOM from other service Pin
dfordurai20-Jun-08 19:20
professionaldfordurai20-Jun-08 19:20 
GeneralSending FAX using C#.net FAXCOMLib -The object identifier does not represent a valid object. (Exception from HRESULT: 0x800710D8) Pin
dfordurai20-Jun-08 19:22
professionaldfordurai20-Jun-08 19:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.