C # method for sending faxes

Source: Internet
Author: User
/**////<summary>
Method of sending a fax, passing three parameters
</summary>
<param name= "Faxfile" ></param>
<param name= "Faxnumber" ></param>
<param name= "HostName" ></param>
public void SendFax (string faxfile, String faxnumber,string hostName)
{

WriteFile ("SendFax faxfile=" +faxfile);
String sql = "";
String faxid = "";
FileInfo f = new FileInfo (faxfile);
if (f.exists)
{
Faxcomlib.faxserver faxsvr = null;
Faxcomlib.faxdoc faxdoc = null;
Try
{
Faxsvr = new Faxcomlib.faxserver ();
Faxdoc = (faxcomlib.faxdoc) faxsvr. CreateDocument (F.fullname);
}
catch (Exception ex)
{
ErrorMessage = ex. message;
WriteFile ("Create Fax Server error!" + errormessage);//environment.machinename
}
Try
{
Faxsvr. Connect (HostName); or specify the computer name Environment.MachineName
}
catch (Exception ex)
{
ErrorMessage = ex. message;
WriteFile ("link Host" +hostname+ "error!" + errormessage);
}

Try
{
Faxdoc. FileName =f.fullname;
Faxdoc. Recipienttitle = "Recipienttitle";
Faxid = F.name;//system.datetime.now.tostring ();
Faxdoc. Recipientzip = Faxid;
WriteFile ("SendFax faxfile=" +faxfile +); F.fullname= "+ Faxdoc. FileName);
//     //-----------------------------------------------------////////
Faxdoc. RecipientAddress = "RecipientAddress";
Faxdoc. Recipientcompany = "Recipientcompany";
Faxdoc. Recipientcountry = "Recipientcountry";
Faxdoc. Recipientdepartment = "Recipientdepartment";
Faxdoc. Recipienthomephone = "Recipienthomephone";
Faxdoc. RecipientName = faxid;/**/////////////Fax ID number
Faxdoc. Recipientoffice = "Recipientoffice";
Faxdoc. Recipientofficephone = "Recipientofficephone";
Faxdoc. sendcoverpage = 0;
Faxdoc. senderaddress = "Senderaddress";
Faxdoc. SenderCompany = "SenderCompany";
Faxdoc. Senderdepartment = "Senderdepartment";
Faxdoc. Senderfax = "Senderfax";
Faxdoc. Senderhomephone = "Senderhomephone";
Faxdoc. Senderofficephone = "Senderofficephone";
Faxdoc. Sendertitle = "Sendertitle";
Faxdoc. Servercoverpage = 1;
Faxdoc. Coverpagename = "Coverpagename";
Faxdoc. Coverpagenote = "Coverpagenote";
Faxdoc. Coverpagesubject = "Coverpagesubject";
//     //------------------------------------------------------//////////
Faxdoc. Faxnumber =faxnumber;//Specify the Fax number;
WriteFile ("f.fullname=" +f.fullname +); Faxdoc. Filename= "+ Faxdoc. FileName);
Intsend = Faxdoc. Send ();
WriteFile ("faxdoc.tsid=" + faxdoc). Sendcoverpage + "; GetHashCode "+ Faxdoc. GetHashCode () + "; FileName: "+ Faxdoc." FileName);
System.Threading.Thread.Sleep (2000);
Faxsvr. Disconnect ();
WriteFile ("Send successfully[" +intsend+ "]" + F.fullname + "" + "(faxnumber:" +faxnumber + "; HostName:" +hostname+ ")" );
sign = 1;
}
catch (Exception ex)
{
ErrorMessage = ex. message;
WriteFile ("Send error[" +intsend+ "]" +f.fullname+ "+errormessage +" (faxnumber: "+faxnumber +"; HostName: " +hostname+ ")");
sign = 0;
System.Threading.Thread.Sleep (5000);
}

}
Else
{
sign = 0;
ErrorMessage = "Error:" +faxfile + "not exist!";
WriteFile (errormessage);
}
if (sign ==0)
{
sql = "UPDATE job_log SET result_message = ' ERROR:" +errormessage.replace ("'", "" ") +" ', log_title= ' "+faxid+" ";
sql = "Where sql like '%" +f.name + "' and event_type = ' FAX '";
Sqlupdate (SQL);

}
else if (sign ==1)
{
sql = "UPDATE job_log SET result_message = ' successfully ', Log_title = '" +faxid+ "";
sql = "Where sql like '%" +f.name + "' and event_type = ' FAX '";
Sqlupdate (SQL);

}

}




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.