how to use .net C# program to fax on the server

T

tanqi

I use C# write some code to fax on the win2003 server, the code is
successful to be compiled, but when I run it on the web page, the error of
system.io.filenotfound occurs. I don't know what the problem is, please help
me.
The code is as following:

using System;
using System.IO;
using System.ComponentModel;
using System.Collections;
using System.Runtime.InteropServices;
using System.Runtime.Remoting;
using System.Diagnostics;
using System.Threading;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Windows.Forms;
using FAXCOMEXLib;

namespace WebFax
{
public class WebForm1 : System.Web.UI.Page

{

protected System.Web.UI.WebControls.Button Button1;

protected System.Web.UI.WebControls.TextBox TextBox2;

protected System.Web.UI.WebControls.TextBox TextBox1;


private void Page_Load(object sender, System.EventArgs e)

{

// Put user code to initialize the page here

}

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}


/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.Button1.Click += new System.EventHandler(this.Button1_Click);

this.TextBox2.TextChanged += new
System.EventHandler(this.TextBox2_TextChanged);

}

#endregion

private void Button1_Click(object sender, System.EventArgs e)

{


TextBox1.Text="hello world";

FaxServerClass fsc = new FaxServerClass();

FaxDocumentClass doc = new FaxDocumentClass();

//variant itest;

try

{



doc.Body = "c:\aaa.txt";

doc.DocumentName ="It is test";

doc.Priority = FAX_PRIORITY_TYPE_ENUM.fptNORMAL;

//doc.CallHandle

doc.Recipients.Add ( "99052865997", "test");

doc.ReceiptType = 0;

// 0 == no receipt, 1 == e-mail, 4 == message box

doc.CoverPageType = 0;

// 0 = no cover page, 1 = local cover page, 2 = server cover page

//doc.CoverPage = String.Format(@"{0}\Proseware.COV", ProsewareDataPath);

// The path to the cover page file. See MS Fax Server Cover Page editor.

doc.Note = "Here is the document you requested.";

// The text of the note printed on the cover page.

doc.ScheduleType = 0;

// 0 == "now" (as soon as possible), 1 = scheduled time,

// 2 = discounted period. See FaxOutgoingQueue.DiscountRateStart, etc.

doc.Subject = "haha";

// All of the following lines set sender information:

doc.Sender.Title = "Mr.";

doc.Sender.Name = "Great Docs Fax Robot";

doc.Sender.City = "Redmond";

doc.Sender.State = "WA";

doc.Sender.Company = "Proseware, Inc.";

doc.Sender.Country = "USA";

doc.Sender.Email = "(e-mail address removed)";

doc.Sender.FaxNumber = "11234567890";

doc.Sender.HomePhone = "10987654321";

doc.Sender.OfficeLocation = "Redmond";

doc.Sender.OfficePhone = "12223334444";

doc.Sender.StreetAddress = "Great Documents Library\nRedmond, WA 98052";

doc.Sender.TSID = "ProsewareFAX";

doc.Sender.ZipCode = "98052";

doc.Sender.BillingCode = "NCC1701C";

doc.Sender.Department = "Library Fax Support";

doc.Sender.SaveDefaultSender();

// This saves the sender information for reuse if you want to send

// the document to multiple recipients using the same sender information.

fsc.Connect("faxmail");

fsc.Connect("faxmail");

// Connects to the fax server. See the second note following this code

// sample for an explanation of why this method is called twice.

//doc.ConnectedSubmit(objFaxServer);

//objFaxServer.Disconnect();



//doc.AttachFaxToReceipt = false;

doc.ConnectedSubmit(fsc);


TextBox2.Text="blank";

fsc.Disconnect();


}


catch(Exception ex)

{

throw (ex);

//MessageBox.Show ("fail to commit file!");

TextBox2.Text="error";



}

finally

{

//MessageBox.Show (itest(0).ToString());

fsc.Disconnect();

//TextBox2.Text="Successful";

}




}
 
R

Renu Bhattar \(MSFT\)

Instead of doc.Body = "c:\aaa.txt", try doc.Body = "c:\\aaa.txt"

---

Renu Bhattar [MSFT]

Microsoft Printing, Imaging and Faxing
This posting isprovided "AS IS" with no warranties and confers no rights.
Please do not send mail directly to this aloas. This alias is for newsgroup
purposes only.
 
T

tanqi

Thank you very much, dear Renu Bhattar. Now the fax server is really working
when I modified the code as you say.
 

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