Sub SendFax() 'version using simple phone number for destination Dim message1, message2 As String Dim XOA As EMsgAPIJobSubmit200907.XOA = New EMsgAPIJobSubmit200907.XOA Dim request As EMsgAPIJobSubmit200907.Request = New EMsgAPIJobSubmit200907.Request Dim authentication As EMsgAPIJobSubmit200907.Authentication = New EMsgAPIJobSubmit200907.Authentication Dim xddsauth As EMsgAPIJobSubmit200907.XDDSAuthType = New EMsgAPIJobSubmit200907.XDDSAuthType Dim jobrequest As EMsgAPIJobSubmit200907.JobSubmitRequest = New EMsgAPIJobSubmit200907.JobSubmitRequest XOA.Url = GetRequestUrl() request.ReceiverKey = GetRequestUrl() 'This returns the URL of PGiConnect Server message1 = "TEST FAX" message2 = "This is a FAX test document" API_Demo.txtResult.Text = "Please wait..." Application.DoEvents() jobrequest.SubmitId = message1 ' WebProxy traps the XML request and response files. If API_Demo.chkUseProxyTrace.Checked Then XOA.Proxy = New System.Net.WebProxy("http://localhost:8080") End If ' Build the SOAP Header xddsauth.RequesterID = API_Demo.txtUserID.Text 'UID xddsauth.Password = API_Demo.txtPassword.Text 'Password authentication.XDDSAuth = xddsauth request.Authentication = authentication request.ReceiverKey = GetRequestUrl() request.ResultRequired = EMsgAPIJobSubmit200907.RequiredType.yes request.RequestID = "Test" XOA.RequestValue = request 'Documents Dim document() As EMsgAPIJobSubmit200907.DocumentType Dim documentdata As EMsgAPIJobSubmit200907.DocDataType = New EMsgAPIJobSubmit200907.DocDataType documentdata.format = EMsgAPIJobSubmit200907.DocEncodingFormat.base64 documentdata.Value = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(message2)) ReDim document(1) document(0) = New EMsgAPIJobSubmit200907.DocumentType document(0).DocType = "text" document(0).ref = "DocOne" Dim myFileName As EMsgAPIJobSubmit200907.EncodableStringType = New EMsgAPIJobSubmit200907.EncodableStringType myFileName.Value = "test12.pdf" document(0).Filename = myFileName document(0).ItemElementName = EMsgAPIJobSubmit200907.ItemChoiceType.DocData document(0).Item = documentdata documentdata = Nothing ' PDF Message Dim inFile As System.IO.FileStream Dim binaryData() As Byte Try inFile = New System.IO.FileStream("C:\Work\TestFiles\PDF\test12.pdf", IO.FileMode.Open, IO.FileAccess.Read) ReDim binaryData(CInt(inFile.Length)) Dim bytesRead As Long = inFile.Read(binaryData, 0, CInt(inFile.Length)) inFile.Close() Catch exp As System.Exception ' Error creating stream or reading from it. MsgBox("Error: {0}", exp.Message) Return End Try 'convert PDF binary into Base64 UUEncoded output: Dim base64String As String Try base64String = System.Convert.ToBase64String(binaryData, 0, binaryData.Length) Catch ex As Exception MsgBox("Error Converting Base64 :" & ex.Message) Return End Try documentdata = New EMsgAPIJobSubmit200907.DocDataType documentdata.format = EMsgAPIJobSubmit200907.DocEncodingFormat.base64 documentdata.Value = base64String document(1) = New EMsgAPIJobSubmit200907.DocumentType document(1).DocType = "PDF" document(1).ref = "DocTwo" myFileName.Value = "test12.pdf" document(1).Filename = myFileName document(1).ItemElementName = EMsgAPIJobSubmit200907.ItemChoiceType.DocData document(1).Item = documentdata documentdata = Nothing 'add the documents to the job request jobrequest.DocumentSet = document ' Build a message Dim message As EMsgAPIJobSubmit200907.MessageType() ReDim message(1) message(0) = New EMsgAPIJobSubmit200907.MessageType ' Contents Dim content() As EMsgAPIJobSubmit200907.ContentPartType ReDim content(1) content(0) = New EMsgAPIJobSubmit200907.ContentPartType content(0).Item = "DocOne" content(0).Treatment = EMsgAPIJobSubmit200907.TreatmentType.body content(0).TreatmentSpecified = True content(1) = New EMsgAPIJobSubmit200907.ContentPartType content(1).Item = "DocTwo" content(1).Treatment = EMsgAPIJobSubmit200907.TreatmentType.attachment content(1).TreatmentSpecified = True ' Add the contents to the message message(0).Contents = content ' Setup job options Dim joboptions As EMsgAPIJobSubmit200907.JobOptionsType = New EMsgAPIJobSubmit200907.JobOptionsType() joboptions.CustomerReference = New EMsgAPIJobSubmit200907.EncodableStringType joboptions.CustomerReference.Value = "JobSubmit_Send Fax" joboptions.BillingCode = New EMsgAPIJobSubmit200907.EncodableStringType joboptions.BillingCode.Value = "JobSubmit_Send Fax" 'setup domain Dim myDomain As String myDomain = "" myDomain = GetDomain() If (myDomain <> "") And (API_Demo.chkDomain.Checked) Then joboptions.Domain = myDomain End If ' Setup Fax options Dim faxoptions As EMsgAPIJobSubmit200907.FaxOptionsType = New EMsgAPIJobSubmit200907.FaxOptionsType faxoptions.FaxMode = EMsgAPIJobSubmit200907.FaxModeType.standard ' Add the Fax options to the job options joboptions.FaxOptions = faxoptions ' Add the job options to the message message(0).JobOptions = joboptions ' Setup reports Dim reports As EMsgAPIJobSubmit200907.ReportOptionsType = New EMsgAPIJobSubmit200907.ReportOptionsType Dim deliveryreport As EMsgAPIJobSubmit200907.ReportOptionsTypeDeliveryReport = New EMsgAPIJobSubmit200907.ReportOptionsTypeDeliveryReport deliveryreport.DeliveryReportType = EMsgAPIJobSubmit200907.MainReportTypeEnum.detail reports.DeliveryReport = deliveryreport ' Add reports to the message message(0).Reports = reports ' Setup delivery destination(s) Dim deliveryFax() As EMsgAPIJobSubmit200907.FaxType ReDim deliveryFax(1) deliveryFax(0) = New EMsgAPIJobSubmit200907.FaxType FaxNumber = API_Demo.txtEmail.Text deliveryFax(0).Phone = FaxNumber message(0).Destinations = deliveryFax jobrequest.Message = message Dim response As EMsgAPIJobSubmit200907.Response = New EMsgAPIJobSubmit200907.Response XOA.ResponseValue = response ' Submit the job request Dim jobresult As EMsgAPIJobSubmit200907.JobSubmitResult = New EMsgAPIJobSubmit200907.JobSubmitResult Try jobresult = XOA.JobSubmit(jobrequest) Catch ex As Exception System.Console.WriteLine("Error: {0}", ex.Message) MsgBox("Error: " & ex.Message) Return End Try 'Process the response Dim success As Boolean success = ProcessResponse(XOA.ResponseValue) 'this just writes the status If (success) Then Dim sJobNumber As String Dim myDateTime, localDateTime As DateTime Debug.Print(jobrequest.ToString) Debug.Print(jobresult.ToString) If jobresult.Status.StatusCode = 0 Then 'case no error Try sJobNumber = jobresult.MessageResult(0).JobId.XDN & ":" & jobresult.MessageResult(0).JobId.MRN Catch ex As Exception MsgBox("Error reading JobID:" & ex.Message) Return End Try API_Demo.txtResult.Text = ("Job Number=" & sJobNumber & vbCrLf & "Result=" & jobresult.Status.StatusCode & vbCrLf & jobresult.Status.StatusMessage) myDateTime = jobresult.MessageResult(0).Status.SubmissionTime localDateTime = myDateTime.ToLocalTime API_Demo.txtResult.Text = API_Demo.txtResult.Text & vbCrLf & "System Time: " & myDateTime.ToString & " " & myDateTime.Kind.ToString API_Demo.txtResult.Text = API_Demo.txtResult.Text & vbCrLf & "Local Time: " & localDateTime.ToString & " " & localDateTime.Kind.ToString Else 'case error API_Demo.txtResult.Text = ("Result=" & jobresult.Status.StatusCode & vbCrLf & jobresult.Status.StatusMessage) End If End If End Sub