//JobSubmitRequest Fax // setup EMsgAPI object - EM EMsgAPI_Demo.EMsgAPI_JobSubmit201101.JobSubmitService EM = new EMsgAPI_Demo.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(); // init Authentication objects XDDSAuth.Password = txtAccessCode.Text; uid.Value = txtUserId.Text; XDDSAuth.RequesterID = uid; //Add to send to Fax2Mail //XDDSAuth.RequesterID.aliasType = "M2F"; reqAuth.Item = XDDSAuth; // Setup MessageObject EMsgAPI_Demo.EMsgAPI_JobSubmit201101.MessageType[] JS_Message = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.MessageType[1]; JS_Message[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.MessageType(); // Setup JobOptions - CREF, Billing Code, FAX EMsgAPI_Demo.EMsgAPI_JobSubmit201101.JobOptionsType JS_JobOptions = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.JobOptionsType(); EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType JS_CRef = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType(); EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType JS_BCode = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType(); EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FaxOptionsType JS_FaxOptions = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FaxOptionsType(); // Set Start and End Time //DateTime StartDateValue = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day, dateTimePicker1.Value.Hour, dateTimePicker1.Value.Minute, 0, dateTimePicker1.Value.Kind); //DateTime EndDateValue = new DateTime(dateTimePicker2.Value.Year, dateTimePicker2.Value.Month, dateTimePicker2.Value.Day, dateTimePicker2.Value.Hour, dateTimePicker2.Value.Minute, 0, dateTimePicker2.Value.Kind); DateTime StartDateValue = new DateTime(); StartDateValue = DateTime.Now.AddHours(1); DateTime EndDateValue = new DateTime(); EndDateValue = DateTime.Now.AddHours(2); EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DeliveryType ScheduledDelivery = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DeliveryType(); ScheduledDelivery.Schedule = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ScheduleType.scheduled; ScheduledDelivery.ScheduleSpecified = true; ScheduledDelivery.StartTimeSpecified = true; ScheduledDelivery.StopTimeSpecified = true; ScheduledDelivery.StartTime = StartDateValue; ScheduledDelivery.StopTime = EndDateValue; //JS_JobOptions.Delivery = ScheduledDelivery; // set CREF and Billing Code if (txtBC.Text.Length > 0) { JS_BCode.Value = txtBC.Text; JS_JobOptions.BillingCode = JS_BCode; } // BC if (txtCRef.Text.Length > 0) { JS_CRef.Value = txtCRef.Text; JS_JobOptions.CustomerReference = JS_CRef; } // CRef // Set FaxOptions //JS_FaxOptions.FaxMode = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FaxModeType.fine; //JS_FaxOptions.FaxModeSpecified = true; // Set Retry Algo JS_FaxOptions.DeliveryRetryPattern = "11"; EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FaxCoversheetOptionType CoverSheet = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FaxCoversheetOptionType(); CoverSheet.UseCoversheet = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.YesNo.yes; //Specify a cover sheet //CoverSheet.CoversheetName = "f2m_default"; EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType CS_To = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType(); CS_To.Value = "Tom"; CoverSheet.CoversheetTo = CS_To; EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType CS_Attn = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType(); CS_Attn.Value = "Mr. Smith"; CoverSheet.CoversheetAttn = CS_Attn; EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType CS_From = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType(); CS_From.Value = "EasyLink"; CoverSheet.CoversheetFrom = CS_From; JS_FaxOptions.FaxCoversheet = CoverSheet; // Setup Insert(s)turn off CSV if using //EMsgAPI_Demo.EMsgAPI_JobSubmit201101.InsertListTypeInsert[] inserts = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.InsertListTypeInsert[2]; //inserts[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.InsertListTypeInsert(); //inserts[0].number = "1"; //inserts[0].Value = "insert 1"; //inserts[1] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.InsertListTypeInsert(); //inserts[1].number = "2"; //inserts[1].Value = "insert 2"; //EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FaxType[] delivery = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FaxType[1]; //delivery[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FaxType(); //delivery[0].InsertList = inserts; //delivery[0].Phone = "8664845098"; //JS_Message[0].Destinations = delivery; //// Setup BannerFX options //EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FaxBannerFxOptionType Banner = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FaxBannerFxOptionType(); //Banner.BannerFxName = "pilot"; //Banner.BannerFxOnCoverSpecified = false; //Banner.BannerFxPlacement = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FaxBannerFxPlacementType.outside; //Banner.BannerFxPlacementSpecified = true; //JS_FaxOptions.BannerFX = Banner; //// Set PilotLine EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FaxPilotlineOptionType PilotLine = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FaxPilotlineOptionType(); switch (txtPilotLine.Text) { case "1": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.PilotlineStyleType.type1; break; case "2": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.PilotlineStyleType.type2; break; case "3": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.PilotlineStyleType.type3; break; case "4": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.PilotlineStyleType.type4; break; case "5": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.PilotlineStyleType.type5; break; case "6": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.PilotlineStyleType.type6; break; case "7": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.PilotlineStyleType.type7; break; case "8": PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.PilotlineStyleType.type8; break; default: PilotLine.PilotlineStyle = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.PilotlineStyleType.none; break; } PilotLine.PilotlineStyleSpecified = true; PilotLine.PilotlineText = "PILOTLINETEXT"; //JS_FaxOptions.Pilotline = PilotLine; //// Set Orientation //JS_FaxOptions.PageOrientation = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.PageOrientationType.landscape; //JS_FaxOptions.PageOrientationSpecified = 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 EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocumentType[] JS_Documents = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocumentType[2]; JS_Documents[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocumentType(); // Setup reusable variables for the document EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocDataType DocData = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocDataType(); string File; //// Setup Document 1 - PDF //File = ReadAndEncodedFile(txtPDFDoc.Text); //DocData.format = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocEncodingFormat.base64; //DocData.Value = File; //JS_Documents[0].Item = DocData; //JS_Documents[0].Filename = "PDF_File.pdf"; //JS_Documents[0].DocType = "PDF"; //JS_Documents[0].ItemElementName = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.ItemChoiceType1.DocData; //JS_Documents[0].@ref = "Doc1"; //DocData = null; // Setup Document 2 - WORD DocData = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocDataType(); File = ReadAndEncodedFile(txtWordDoc.Text, true); DocData.format = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocEncodingFormat.base64; DocData.Value = File; JS_Documents[0].Item = DocData; EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType myFileName = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType(); myFileName.Value = "Word_File.doc"; JS_Documents[0].Filename = myFileName; JS_Documents[0].DocType = "MSW"; JS_Documents[0].ItemElementName = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ItemChoiceType.DocData; JS_Documents[0].@ref = "Doc1"; DocData = null; //// Setup Document 3 - Text //DocData = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocDataType(); ////File = ReadAndEncodedFile(txtWordDoc.Text, true); //DocData.format = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocEncodingFormat.text; //DocData.Value = "This is a test document"; //JS_Documents[0].Item = DocData; //JS_Documents[0].Filename = "text.txt"; //JS_Documents[0].DocType = "text"; //JS_Documents[0].ItemElementName = EMsgAPI_Demo.EMsgAPI_JobSubmit_200907.ItemChoiceType.DocData; //JS_Documents[0].@ref = "Doc1"; //DocData = null; if (UseCSVList.Checked == true) { // Setup Document 3 - CSV List DocData = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocDataType(); File = ReadAndEncodedFile(txtCSVList.Text, true); DocData.format = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocEncodingFormat.base64; DocData.Value = File; JS_Documents[1] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocumentType(); JS_Documents[1].Item = DocData; myFileName.Value = "CSVList.csv"; JS_Documents[1].Filename = myFileName; JS_Documents[1].DocType = "text"; JS_Documents[1].ItemElementName = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ItemChoiceType.DocData; JS_Documents[1].@ref = "CSVList1"; DocData = null; } // (UseCSVList.Checked == true) // Setup Content EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ContentsType EM_Content = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ContentsType(); EM_Content = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ContentsType(); EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ContentPartType[] JS_Content = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ContentPartType[1]; JS_Content[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ContentPartType(); //JS_Content[1] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ContentPartType(); // Setup references to documents JS_Content[0].Item = "Doc1"; JS_Content[0].Treatment = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.TreatmentType.body; JS_Content[0].TreatmentSpecified = true; //JS_Content[1].Item = "WordDoc1"; //JS_Content[1].Treatment = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.TreatmentType.attachment; //JS_Content[1].TreatmentSpecified = true; if (UseCSVList.Checked == true) // Pass in a CSV List with Job Submit { // Setup table for list // List was loaded in document section must be added as a Table in Content Section EMsgAPI_Demo.EMsgAPI_JobSubmit201101.TableType[] CSVList_Table = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.TableType[1]; CSVList_Table[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.TableType(); CSVList_Table[0].Item = "CSVList1"; CSVList_Table[0].@ref = "CSVList_Table1"; //Turn off if using inserts JS_Message[0].Destinations = CSVList_Table; CSVList_Table = null; } else // Use a previously stored list { // Setup List Object EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ListType[] lists = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ListType[1]; lists[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ListType(); lists[0].ownershipLevel = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.OwnershipLevelType.customer; lists[0].ownershipLevelSpecified = true; lists[0].Name = txtStoredList.Text; // Name of stored list lists[0].@ref = "Stored Fax List"; JS_Message[0].Destinations = lists; lists = null; } //EM_Content.DynamicContent = JS_Content; 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 EMsgAPI_Demo.EMsgAPI_JobSubmit201101.Request Request = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.Request(); EMsgAPI_Demo.EMsgAPI_JobSubmit201101.Response Response = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.Response(); EMsgAPI_Demo.EMsgAPI_JobSubmit201101.JobSubmitRequest JS_Request = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.JobSubmitRequest(); EMsgAPI_Demo.EMsgAPI_JobSubmit201101.JobSubmitResult JS_Result = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.JobSubmitResult(); // Setup Proxy server and EMsgAPIConnect URL for posting data Set_Server_and_Proxy(EM); // Setup Reqeust Object if (cmbServer.Text.Contains("Async")) { Request.SenderKey = "http://www.bdrsoftware.com/Service1.asmx"; } // 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; try { if (cmbServer.Text.Contains("Async")) { EM.JobSubmit(JS_Request); JS_Result = null; } else JS_Result = EM.JobSubmit(JS_Request); } catch (Exception ex) { 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; txtJobNumber.Text = JobNumber; } } 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 if (chkResult) { serializeResult(emfilename, EM.ResponseValue); serializeResult(resfilename, JS_Result); //serializeResult(reqfilename, JS_Request); } } catch (IOException io_error) { MessageBox.Show("Error - " + io_error, "Error", MessageBoxButtons.OK); }