Sub SendEnhancedEmailLongList() 'advanced version using a long table and inserts. 'Text Document to simulate CSD Jobs 'This part of the code is the same for all commands: Dim EM As EMsgAPIJobSubmit201101.JobSubmitService = New EMsgAPIJobSubmit201101.JobSubmitService Dim request As EMsgAPIJobSubmit201101.Request = New EMsgAPIJobSubmit201101.Request Dim authentication As EMsgAPIJobSubmit201101.RequestAuthentication = New EMsgAPIJobSubmit201101.RequestAuthentication Dim xddsauth As EMsgAPIJobSubmit201101.XDDSAuthType = New EMsgAPIJobSubmit201101.XDDSAuthType Dim jobrequest As EMsgAPIJobSubmit201101.JobSubmitRequest = New EMsgAPIJobSubmit201101.JobSubmitRequest Dim uid As EMsgAPIJobSubmit201101.UIDType = New EMsgAPIJobSubmit201101.UIDType ' Set the URL EM.Url = GetRequestUrl() ' Build the SOAP Header uid.Value = API_Demo.txtUserID.Text xddsauth.RequesterID = uid 'UID xddsauth.Password = API_Demo.txtPassword.Text 'Password authentication.Item = xddsauth request.Authentication = authentication request.ReceiverKey = GetRequestUrl() 'request.ResultRequired = EMsgAPIJobSubmit201101.RequiredType.yes request.RequestID = "Test PGS Email" EM.RequestValue = request If API_Demo.chkUseProxyTrace.Checked Then EM.Proxy = New System.Net.WebProxy("http://localhost:8080") End If ' Create Message Object Dim message As EMsgAPIJobSubmit201101.MessageType() ReDim message(1) message(0) = New EMsgAPIJobSubmit201101.MessageType Dim doctype As EMsgAPIJobSubmit201101.DocumentType = New EMsgAPIJobSubmit201101.DocumentType Dim joboptions As EMsgAPIJobSubmit201101.JobOptionsType = New EMsgAPIJobSubmit201101.JobOptionsType Dim CustomerReference As New EMsgAPIJobSubmit201101.EncodableStringType CustomerReference.Value = "EM MessageREACH Job" joboptions.CustomerReference = CustomerReference joboptions.BillingCode = CustomerReference 'This part of the code will depend on the command: Dim emailOptions As EMsgAPIJobSubmit201101.EnhancedEmailOptionsType = New EMsgAPIJobSubmit201101.EnhancedEmailOptionsType Dim subject As New EMsgAPIJobSubmit201101.EncodableStringType subject.Value = "Hello (i1) PGiConnect Test" 'emailOptions.FromDisplayName = "Premiere Garet" 'emailOptions.ReplyTo = "ReplyEmail@pgi.com" emailOptions.Subject = subject 'emailOptions.HTMLOpenTracking = EMsgAPIJobSubmit201101.HTMLOpenTrackingType.top 'emailOptions.HTMLOpenTrackingSpecified = True ' joboptions.EnhancedEmailOptions = emailOptions message(0).JobOptions = joboptions joboptions = Nothing emailOptions = Nothing Dim document As EMsgAPIJobSubmit201101.DocumentType() ReDim document(3) document(0) = New EMsgAPIJobSubmit201101.DocumentType document(1) = New EMsgAPIJobSubmit201101.DocumentType 'document(2) = New EMsgAPIJobSubmit201101.DocumentType Dim documentdata As EMsgAPIJobSubmit201101.DocDataType = New EMsgAPIJobSubmit201101.DocDataType documentdata.format = EMsgAPIJobSubmit201101.DocEncodingFormat.text documentdata.Value = "Hi (i1), " & vbCrLf & _ "This is a test message from Premiere Global Services. Please ignore this email." ' Set Document 0 - Text Body Message document(0).Item = documentdata document(0).ItemElementName = EMsgAPIJobSubmit201101.ItemChoiceType.DocData document(0).DocType = "text" document(0).ref = "email_text" documentdata = Nothing ' USED TO READ IN CSV LIST AND HTML Dim inCSVFile As System.IO.StreamReader Dim fileData As String ' HTML Message 'Try ' inCSVFile = New System.IO.StreamReader("c:\work\testfiles\Body Messages\body1.htm") ' fileData = inCSVFile.ReadToEnd() ' inCSVFile.Close() 'Catch exp As System.Exception ' ' Error creating stream or reading from it. ' System.Console.WriteLine("{0}", exp.Message) ' Return 'End Try 'documentdata = New EMsgAPIJobSubmit201101.DocDataType 'documentdata.format = EMsgAPIJobSubmit201101.DocEncodingFormat.base64 'documentdata.Value = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(fileData)) 'document(1).Item = documentdata 'documentdata = Nothing 'document(1).ItemElementName = EMsgAPIJobSubmit201101.ItemChoiceType1.DocData 'document(1).DocType = "HTML" 'document(1).ref = "email_html_text" ' CSV LIST Try inCSVFile = New System.IO.StreamReader("C:\Work\TestFiles\lists\email_test_biglist.csv") 'inCSVFile = New System.IO.StreamReader("C:\Work\TestFiles\lists\email_test_longlist_bad.csv") fileData = inCSVFile.ReadToEnd() inCSVFile.Close() Catch exp As System.Exception ' Error creating stream or reading from it. System.Console.WriteLine("{0}", exp.Message) Return End Try documentdata = New EMsgAPIJobSubmit201101.DocDataType documentdata.format = EMsgAPIJobSubmit201101.DocEncodingFormat.base64 documentdata.Value = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(fileData)) document(1).ItemElementName = EMsgAPIJobSubmit201101.ItemChoiceType.DocData document(1).ref = "docREF_CSV" document(1).Item = documentdata Dim myFileName As EMsgAPIJobSubmit201101.EncodableStringType = New EMsgAPIJobSubmit201101.EncodableStringType myFileName.Value = "email_test.csv" document(0).Filename = myFileName document(1).DocType = "text" documentdata = Nothing Dim content() As EMsgAPIJobSubmit201101.ContentPartType Dim contentstype As EMsgAPIJobSubmit201101.ContentsType ReDim content(2) content(0) = New EMsgAPIJobSubmit201101.ContentPartType contentstype = New EMsgAPIJobSubmit201101.ContentsType contentstype.Part = content content(0).Item = "email_text" content(0).Treatment = EMsgAPIJobSubmit201101.TreatmentType.body content(0).TreatmentSpecified = True 'content(1) = New EMsgAPIJobSubmit201101.ContentPartType 'content(1).Item = "email_html_text" 'content(1).Treatment = EMsgAPIJobSubmit201101.TreatmentType.body 'content(1).TreatmentSpecified = True message(0).Contents = contentstype Dim reports As EMsgAPIJobSubmit201101.ReportOptionsType = New EMsgAPIJobSubmit201101.ReportOptionsType Dim deliveryreport As EMsgAPIJobSubmit201101.ReportOptionsTypeDeliveryReport = New EMsgAPIJobSubmit201101.ReportOptionsTypeDeliveryReport deliveryreport.DeliveryReportType = EMsgAPIJobSubmit201101.MainReportTypeEnum.detail reports.DeliveryReport = deliveryreport deliveryreport = Nothing message(0).Reports = reports reports = Nothing Dim table() As EMsgAPIJobSubmit201101.TableType ReDim table(0) table(0) = New EMsgAPIJobSubmit201101.TableType table(0).Item = "docREF_CSV" table(0).ref = "tblREF_CSV" message(0).Destinations = table jobrequest.Message = message jobrequest.DocumentSet = document Dim jobresult As EMsgAPIJobSubmit201101.JobSubmitResult = New EMsgAPIJobSubmit201101.JobSubmitResult EM.RequestValue = request Dim response As EMsgAPIJobSubmit201101.Response = New EMsgAPIJobSubmit201101.Response EM.ResponseValue = response Try jobresult = EM.JobSubmit(jobrequest) Catch ex As System.Web.Services.Protocols.SoapException MsgBox(ex.Message) End Try Dim sJobNumber As String sJobNumber = jobresult.MessageResult(0).JobId.XDN & ":" & jobresult.MessageResult(0).JobId.MRN API_Demo.txtResult.Text = ("Job Number = " & sJobNumber & vbCrLf & "Result=" & jobresult.Status.StatusCode & vbCrLf & jobresult.Status.StatusMessage) End Sub