首页 > 开发 > 综合 > 正文

发送传真的c#方法

2024-07-21 02:26:32
字体:
来源:转载
供稿:网友

/**//// <summary>
  /// ////发送传真的方法,传递三个参数
  /// </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;/**/////////////传真id号
     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);

   }

  }


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表