{ //JobSubmitRequest Fax MM Coversheet with FieldMapping // setup EMsgAPI object - EM Fax.EMsgAPI_JobSubmit201101.JobSubmitService EM = new Fax.EMsgAPI_JobSubmit201101.JobSubmitService(); // setup Authentication objects EMsgAPI_JobSubmit201101.RequestAuthentication reqAuth = new EMsgAPI_JobSubmit201101.RequestAuthentication(); EMsgAPI_JobSubmit201101.XDDSAuthType XDDSAuth = new EMsgAPI_JobSubmit201101.XDDSAuthType(); EMsgAPI_JobSubmit201101.UIDType uid = new EMsgAPI_JobSubmit201101.UIDType(); EMsgAPI_JobSubmit201101.UIDType uid2 = new EMsgAPI_JobSubmit201101.UIDType(); // init Authentication objects XDDSAuth.Password = "mypassword"; uid.Value = "myuserid"; //uid2.Value = "tgargiulo@easylink.com"; XDDSAuth.RequesterID = uid; //XDDSAuth.TargetID = uid2; //XDDSAuth.TargetID.aliasType = "F2M"; reqAuth.Item = XDDSAuth; // Setup MessageObject Fax.EMsgAPI_JobSubmit201101.MessageType[] JS_Message = new Fax.EMsgAPI_JobSubmit201101.MessageType[1]; JS_Message[0] = new Fax.EMsgAPI_JobSubmit201101.MessageType(); // Setup JobOptions - CREF, Billing Code, FAX Fax.EMsgAPI_JobSubmit201101.JobOptionsType JS_JobOptions = new Fax.EMsgAPI_JobSubmit201101.JobOptionsType(); Fax.EMsgAPI_JobSubmit201101.EncodableStringType JS_CRef = new Fax.EMsgAPI_JobSubmit201101.EncodableStringType(); Fax.EMsgAPI_JobSubmit201101.EncodableStringType JS_BCode = new Fax.EMsgAPI_JobSubmit201101.EncodableStringType(); Fax.EMsgAPI_JobSubmit201101.FaxOptionsType JS_FaxOptions = new Fax.EMsgAPI_JobSubmit201101.FaxOptionsType(); // set CREF and Billing Code JS_BCode.Value = "BillCode"; JS_JobOptions.BillingCode = JS_BCode; JS_CRef.Value = "CREF"; JS_JobOptions.CustomerReference = JS_CRef; // Set FaxOptions Fax.EMsgAPI_JobSubmit201101.FaxCoversheetOptionType CoverSheet = new Fax.EMsgAPI_JobSubmit201101.FaxCoversheetOptionType(); CoverSheet.UseCoversheet = Fax.EMsgAPI_JobSubmit201101.YesNo.yes; CoverSheet.CoversheetName = "f2m_default"; JS_FaxOptions.FaxCoversheet = CoverSheet; JS_FaxOptions.FaxMode = Fax.EMsgAPI_JobSubmit201101.FaxModeType.standard; JS_FaxOptions.FaxModeSpecified = true; // Set JobOptions as FaxOptions JS_JobOptions.FaxOptions = JS_FaxOptions; // Set Message Object JS_Message[0].JobOptions = JS_JobOptions; // Free Objects //JS_JobOptions = null; //JS_FaxOptions = null; //JS_CRef = null; //JS_BCode = null; // Setup Documents Fax.EMsgAPI_JobSubmit201101.DocumentType[] JS_Documents = new Fax.EMsgAPI_JobSubmit201101.DocumentType[2]; JS_Documents[0] = new Fax.EMsgAPI_JobSubmit201101.DocumentType(); Fax.EMsgAPI_JobSubmit201101.DocDataType DocData1 = new Fax.EMsgAPI_JobSubmit201101.DocDataType(); string File1; //// Setup Document 1 - CSV File1 = ReadAndEncodedFile("fmapfax.csv"); DocData1.format = Fax.EMsgAPI_JobSubmit201101.DocEncodingFormat.base64; DocData1.Value = File1; JS_Documents[0].Item = DocData1; Fax.EMsgAPI_JobSubmit201101.EncodableStringType myFileName1 = new Fax.EMsgAPI_JobSubmit201101.EncodableStringType(); myFileName1.Value = "fmapfax"; //myFileName1.Value = "fmapfax.csv"; JS_Documents[0].Filename = myFileName1; JS_Documents[0].DocType = "text"; JS_Documents[0].ItemElementName = Fax.EMsgAPI_JobSubmit201101.ItemChoiceType.DocData; JS_Documents[0].@ref = "CSV"; //// Setup Document 2 - empty JS_Documents[1] = new Fax.EMsgAPI_JobSubmit201101.DocumentType(); Fax.EMsgAPI_JobSubmit201101.DocDataType DocData2 = new Fax.EMsgAPI_JobSubmit201101.DocDataType(); string File2; //File2 = " "; DocData2.format = Fax.EMsgAPI_JobSubmit201101.DocEncodingFormat.text; //DocData2.Value = File2; DocData2.Value = " "; JS_Documents[1].Item = DocData2; Fax.EMsgAPI_JobSubmit201101.EncodableStringType myFileName2 = new Fax.EMsgAPI_JobSubmit201101.EncodableStringType(); myFileName2.Value = "empty.txt"; //myFileName2.Value = "myempty"; JS_Documents[1].Filename = myFileName2; JS_Documents[1].DocType = "empty"; JS_Documents[1].ItemElementName = Fax.EMsgAPI_JobSubmit201101.ItemChoiceType.DocData; JS_Documents[1].@ref = "Doc1"; // Setup Content Fax.EMsgAPI_JobSubmit201101.ContentsType EM_Content = new Fax.EMsgAPI_JobSubmit201101.ContentsType(); EM_Content = new Fax.EMsgAPI_JobSubmit201101.ContentsType(); Fax.EMsgAPI_JobSubmit201101.ContentPartType[] JS_Content = new Fax.EMsgAPI_JobSubmit201101.ContentPartType[1]; JS_Content[0] = new Fax.EMsgAPI_JobSubmit201101.ContentPartType(); // Setup references to documents JS_Content[0].Item = "Doc1"; JS_Content[0].Treatment = Fax.EMsgAPI_JobSubmit201101.TreatmentType.body; JS_Content[0].TreatmentSpecified = true; //Setup FieldMapping Fax.EMsgAPI_JobSubmit201101.TableType[] tabletype = new Fax.EMsgAPI_JobSubmit201101.TableType[1]; tabletype[0] = new Fax.EMsgAPI_JobSubmit201101.TableType(); tabletype[0].@ref = "tbl_csv"; tabletype[0].Item = "CSV"; Fax.EMsgAPI_JobSubmit201101.FieldMappingTypeMap[] mapObj = new Fax.EMsgAPI_JobSubmit201101.FieldMappingTypeMap[5]; mapObj[0] = new Fax.EMsgAPI_JobSubmit201101.FieldMappingTypeMap(); mapObj[0].FieldName = "REF"; mapObj[0].PropertyName = "REF"; mapObj[1] = new Fax.EMsgAPI_JobSubmit201101.FieldMappingTypeMap(); mapObj[1].FieldName = "TYPE"; mapObj[1].PropertyName = "ADDR_TYPE"; mapObj[2] = new Fax.EMsgAPI_JobSubmit201101.FieldMappingTypeMap(); mapObj[2].FieldName = "ADDR"; mapObj[2].PropertyName = "TO"; mapObj[3] = new Fax.EMsgAPI_JobSubmit201101.FieldMappingTypeMap(); mapObj[3].FieldName = "OWNER"; mapObj[3].SegmentName = "INSERTS"; mapObj[3].PropertyName = "INSERT[1]"; mapObj[4] = new Fax.EMsgAPI_JobSubmit201101.FieldMappingTypeMap(); mapObj[4].FieldName = "DRUG"; mapObj[4].SegmentName = "INSERTS"; mapObj[4].PropertyName = "INSERT[2]"; tabletype[0].FieldMapping = mapObj; JS_Message[0].Destinations = tabletype; EM_Content.Part = JS_Content; JS_Message[0].Contents = EM_Content; //JS_Message[0].MessageId = System.Environment.MachineName + DateTime.Now; //JS_Content = null; // Everything is Setup Prepare to Launch Job // Setup Request and JobSubmitRequest object Fax.EMsgAPI_JobSubmit201101.Request Request = new Fax.EMsgAPI_JobSubmit201101.Request(); Fax.EMsgAPI_JobSubmit201101.Response Response = new Fax.EMsgAPI_JobSubmit201101.Response(); Fax.EMsgAPI_JobSubmit201101.JobSubmitRequest JS_Request = new Fax.EMsgAPI_JobSubmit201101.JobSubmitRequest(); Fax.EMsgAPI_JobSubmit201101.JobSubmitResult JS_Result = new Fax.EMsgAPI_JobSubmit201101.JobSubmitResult(); // Setup Proxy server and EMsgAPIConnect URL for posting data Set_Server_and_Proxy(EM); // Setup Reqeust Object Request.ReceiverKey = EM.Url; Request.Authentication = reqAuth; Request.RequestID = "RequestID"; JS_Request.SubmitId = "SubmitId"; // Assign Reqeust and Response objects to EM Object EM.RequestValue = Request; EM.ResponseValue = Response; JS_Request.Message = JS_Message; JS_Request.DocumentSet = JS_Documents; string reqfilename1 = "request1.xml"; serializeResult(reqfilename1, JS_Request); try { JS_Result = EM.JobSubmit(JS_Request); } catch (Exception ex) { string emfilename1 = "emresponse1.xml"; serializeResult(emfilename1, EM.ResponseValue); string resfilename1 = "result1.xml"; serializeResult(resfilename1, JS_Result); System.Console.WriteLine(ex.Message); System.Console.Read(); return; } if (JS_Result != null) { if (JS_Result.Status.StatusCode != null) { //string JobNumber; //JobNumber = JS_Result.MessageResult[0].JobId.XDN + ":" + JS_Result.MessageResult[0].JobId.MRN; } } string reqfilename = "request.xml"; string emfilename = "emresponse.xml"; string resfilename = "result.xml"; //string reqfilename = "request.xml"; try { //This will output the response, result and request(if uncommented) to XML files in the //installed directory. This can be very usefull for debugging or ir help is requested from //the EMAPI support team serializeResult(reqfilename, JS_Request); serializeResult(emfilename, EM.ResponseValue); serializeResult(resfilename, JS_Result); } catch (IOException io_error) { MessageBox.Show("Error - " + io_error, "Error", MessageBoxButtons.OK); } }