private void JobSubmitRequestEnhancedEmail_Click(object sender, EventArgs e) { //EnhancedEmail multi // 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; 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.EnhancedEmailOptionsType JS_EnhancedEmailOptions = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EnhancedEmailOptionsType(); // set CREF and Billing Code JS_CRef.Value = txtCRef.Text; JS_BCode.Value = txtBC.Text; JS_JobOptions.CustomerReference = JS_CRef; JS_JobOptions.BillingCode = JS_BCode; //// 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); EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DeliveryType ScheduledDelivery = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DeliveryType(); ScheduledDelivery.Schedule = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ScheduleType.express; //ScheduledDelivery.ScheduleSpecified = true; //ScheduledDelivery.StartTimeSpecified = true; //ScheduledDelivery.StopTimeSpecified = true; //ScheduledDelivery.StartTime = StartDateValue; //ScheduledDelivery.StopTime = EndDateValue; JS_JobOptions.Delivery = ScheduledDelivery; // Set EnhancedEmailOptions // Set Expiration JS_EnhancedEmailOptions.ExpirationDays = 1; JS_EnhancedEmailOptions.ExpirationDaysSpecified = true; // Set HTML Open Tracking JS_EnhancedEmailOptions.HTMLOpenTracking = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.HTMLOpenTrackingType.top; JS_EnhancedEmailOptions.HTMLOpenTrackingSpecified = true; // Set Subject EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType Email_Subject = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType(); Email_Subject.Value = txtEnhancedSubject.Text; JS_EnhancedEmailOptions.Subject = Email_Subject; // Set From Information JS_EnhancedEmailOptions.FromDisplayName = "My Name"; // Friendly From //JS_EnhancedEmailOptions.ReplyTo = "myreplyto@hotmail.com"; //JS_EnhancedEmailOptions.FromAddress = "myfrom addreess@gmail.com"; // Spoofed From //// Set SendAFriend Options //JS_EnhancedEmailOptions.AutoSendFriend = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.YesNo.yes; //JS_EnhancedEmailOptions.AutoSendFriendSpecified = true; // Set JobOptions as EnhancedEmailOptions JS_JobOptions.EnhancedEmailOptions = JS_EnhancedEmailOptions; // Set Message Object JS_Message[0].JobOptions = JS_JobOptions; // Free Objects JS_JobOptions = null; JS_EnhancedEmailOptions = null; JS_CRef = null; JS_BCode = null; Email_Subject = null; // Setup Documents EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocumentType[] JS_Documents = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocumentType[5]; JS_Documents[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocumentType(); JS_Documents[1] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocumentType(); JS_Documents[2] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocumentType(); JS_Documents[3] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocumentType(); JS_Documents[4] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocumentType(); //JS_Documents[5] = 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 - HTML Body File = ReadAndEncodedFile(txtHTMLBody.Text); DocData.format = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocEncodingFormat.base64; DocData.Value = File; JS_Documents[0].Item = DocData; JS_Documents[0].DocType = "HTML"; JS_Documents[0].ItemElementName = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ItemChoiceType.DocData; JS_Documents[0].@ref = "HTML_Body"; DocData = null; // Setup Document 2 - TEXT Body DocData = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocDataType(); File = ReadAndEncodedFile(txtTEXTBody.Text, true); DocData.format = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocEncodingFormat.base64; DocData.Value = File; JS_Documents[1].Item = DocData; EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType myFileName = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.EncodableStringType(); myFileName.Value = "TEXT_Body.txt"; JS_Documents[1].Filename = myFileName; JS_Documents[1].DocType = "text"; JS_Documents[1].ItemElementName = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ItemChoiceType.DocData; JS_Documents[1].@ref = "TEXT_Body"; DocData = null; // 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[2].Item = DocData; myFileName.Value = "CSVList.csv"; JS_Documents[2].Filename = myFileName; JS_Documents[2].DocType = "text"; JS_Documents[2].ItemElementName = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ItemChoiceType.DocData; JS_Documents[2].@ref = "CSVList1"; DocData = null; //// Setup Document - Pull File 1 //DocData = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocDataType(); //File = ReadAndEncodedFile(txtPull1.Text, true); //DocData.format = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocEncodingFormat.base64; //DocData.Value = File; // Get Filename information along with Extension //System.IO.FileInfo oFileInfo = new System.IO.FileInfo(txtAttach1.Text); //JS_Documents[3].Item = DocData; //JS_Documents[3].Filename = oFileInfo.Name; //JS_Documents[3].DocType = "HTML"; //JS_Documents[3].ItemElementName = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ItemChoiceType.DocData; //JS_Documents[3].@ref = "PULL1"; //DocData = null; //oFileInfo = null; //// Setup Document - Pull File 2 //DocData = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocDataType(); //File = ReadAndEncodedFile(txtPull2.Text, true); //DocData.format = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocEncodingFormat.base64; //DocData.Value = File; //// Get Filename information along with Extension //oFileInfo = new System.IO.FileInfo(txtPull2.Text); //JS_Documents[4].Item = DocData; //JS_Documents[4].Filename = oFileInfo.Name; //JS_Documents[4].DocType = "JPEG"; //JS_Documents[4].ItemElementName = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ItemChoiceType.DocData; //JS_Documents[4].@ref = "PULL2"; //DocData = null; //oFileInfo = null; // Setup Document - Attachment 1 DocData = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocDataType(); File = ReadAndEncodedFile(txtAttach1.Text, true); DocData.format = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocEncodingFormat.base64; DocData.Value = File; // Get Filename information along with Extension System.IO.FileInfo oFileInfo = new System.IO.FileInfo(txtAttach1.Text); JS_Documents[3].Item = DocData; myFileName.Value = oFileInfo.Name; JS_Documents[3].Filename = myFileName; JS_Documents[3].DocType = "PDF"; JS_Documents[3].ItemElementName = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ItemChoiceType.DocData; JS_Documents[3].@ref = "ATTACH1"; DocData = null; oFileInfo = null; // Setup Document - Attachment 2 DocData = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocDataType(); File = ReadAndEncodedFile(txtPull2.Text, true); DocData.format = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.DocEncodingFormat.base64; DocData.Value = File; // Get Filename information along with Extension oFileInfo = new System.IO.FileInfo(txtAttach1.Text); JS_Documents[4].Item = DocData; myFileName.Value = oFileInfo.Name; JS_Documents[4].Filename = myFileName; JS_Documents[4].DocType = "MSW"; JS_Documents[4].ItemElementName = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ItemChoiceType.DocData; JS_Documents[4].@ref = "ATTACH2"; DocData = null; oFileInfo = null; // Setup Content // 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[4]; JS_Content[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ContentPartType(); JS_Content[1] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ContentPartType(); JS_Content[2] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ContentPartType(); JS_Content[3] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ContentPartType(); //JS_Content[4] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ContentPartType(); // Setup references to documents JS_Content[0].Item = "HTML_Body"; JS_Content[0].Treatment = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.TreatmentType.body; JS_Content[0].TreatmentSpecified = true; JS_Content[1].Item = "TEXT_Body"; JS_Content[1].Treatment = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.TreatmentType.body; JS_Content[1].TreatmentSpecified = true; //JS_Content[2].Item = "PULL1"; //JS_Content[2].Treatment = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.TreatmentType.pullfile; //JS_Content[2].TreatmentSpecified = true; ////EMsgAPI_Demo.EMsgAPI_JobSubmit201101.PullfileOptionsType PullFileOptions = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.PullfileOptionsType(); ////PullFileOptions.AutoPull = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.YesNo.no; ////PullFileOptions.AutoPullSpecified = true; ////JS_Content[2].PullfileOptions = PullFileOptions; ////PullFileOptions = null; //JS_Content[3].Item = "PULL2"; //JS_Content[3].Treatment = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.TreatmentType.pullfile; //JS_Content[3].TreatmentSpecified = true; ////PullFileOptions = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.PullfileOptionsType(); ////PullFileOptions.AutoPull = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.YesNo.yes; ////PullFileOptions.AutoPullSpecified = true; ////JS_Content[3].PullfileOptions = PullFileOptions; ////PullFileOptions = null; JS_Content[2].Item = "ATTACH1"; JS_Content[2].Treatment = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.TreatmentType.attachment; JS_Content[2].TreatmentSpecified = true; JS_Content[3].Item = "ATTACH2"; JS_Content[3].Treatment = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.TreatmentType.attachment; JS_Content[3].TreatmentSpecified = true; // Setup Content Object (documents are referenced here) // Setup table for list 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"; // Setup ALL Report Options EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ReportOptionsType JS_Report = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ReportOptionsType(); // Setup Delivery Report EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ReportOptionsTypeDeliveryReport JS_Delivery_Report = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ReportOptionsTypeDeliveryReport(); JS_Delivery_Report.DeliveryReportType = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.MainReportTypeEnum.none; JS_Report.DeliveryReport = JS_Delivery_Report; // Setup Final Report EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ReportOptionsTypeFinalReport JS_Final_Report = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ReportOptionsTypeFinalReport(); JS_Final_Report.ReportType = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.AllReportTypeEnum.none; JS_Report.FinalReport = JS_Final_Report; // Setup Progress Report EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ReportOptionsTypeProgressReport JS_Progress_Report = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ReportOptionsTypeProgressReport(); JS_Progress_Report.ProgressReportType = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.AllReportTypeEnum.none; JS_Report.ProgressReport = JS_Progress_Report; JS_Progress_Report.ProgressReportType = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.AllReportTypeEnum.conditional; EMsgAPI_Demo.EMsgAPI_JobSubmit201101.InternetType[] JS_Report_Address = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.InternetType[1]; JS_Report_Address[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.InternetType(); JS_Report_Address[0].Email = "thuneke@easylink.com"; JS_Progress_Report.ReportAddress = JS_Report_Address; JS_Progress_Report.ProgressReportIntervals = "5 10"; DateTime BaseValue = DateTime.Now; JS_Progress_Report.ProgressReportBase = BaseValue.AddMinutes(5); JS_Progress_Report.ProgressReportBaseSpecified = true; JS_Report.ProgressReport = JS_Progress_Report; // Setup Friend Report EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ReportOptionsTypeFriendReport JS_Friend_Report = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ReportOptionsTypeFriendReport(); JS_Friend_Report.FriendReportType = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FriendReportTypeEnum.none; JS_Report.FriendReport = JS_Friend_Report; //EMsgAPI_Demo.EMsgAPI_JobSubmit201101.InternetType[] JS_Friend_Address = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.InternetType[1]; //JS_Friend_Address[0] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.InternetType(); //JS_Friend_Address[0].Email = "myaddress@something.com"; //JS_Friend_Report.ReportAddress = JS_Friend_Address; //JS_Friend_Report.FriendReportType = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FriendReportTypeEnum.detail; JS_Report.FriendReport = JS_Friend_Report; JS_Message[0].Reports = JS_Report; EM_Content.Part = JS_Content; JS_Message[0].Contents = EM_Content; JS_Message[0].Destinations = CSVList_Table; JS_Message[0].MessageId = System.Environment.MachineName + DateTime.Now; // Free Objects CSVList_Table = null; JS_Content = null; //// Setup Object for List Information (this is for a stored list) //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.user; //Lists[0].ownershipLevelSpecified = true; //Lists[0].Name = "bruceemail"; //Lists[0].@ref = "bruceemail"; //JS_Message[0].Destinations = Lists; //Lists = null; // Everything is Setup Prepare to Launch Job // First check to see if we need to setup proxy // 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; // Assign Reqeust and Response objects to EM Object EM.RequestValue = Request; EM.ResponseValue = Response; JS_Request.Message = JS_Message; JS_Request.DocumentSet = JS_Documents; JS_Request.SubmitId = "SUBMITID_EMAIL"; 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); } }