Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Load .eml and Examine the Structure, Attachments, and Related ItemsDemonstrates how to load examine the MIME structure of a .eml, and also examine the attachment and related item filenames, attached messages, and multipart/report and DSN information.
integer li_rc string ls_EmlPath oleobject loo_Mime integer li_Success oleobject loo_Email integer i integer li_NumAttach integer li_NumRelated integer li_NumAttachedMessages oleobject loo_Em integer li_NumReports oleobject loo_Sa integer li_NumFinalRecipients // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. ls_EmlPath = "C:/AAWorkarea/beatrix/roesner.eml" loo_Mime = create oleobject // Use "Chilkat_9_5_0.Mime" for versions of Chilkat < 10.0.0 li_rc = loo_Mime.ConnectToNewObject("Chilkat.Mime") if li_rc < 0 then destroy loo_Mime MessageBox("Error","Connecting to COM object failed") return end if li_Success = loo_Mime.LoadMimeFile(ls_EmlPath) if li_Success <> 1 then Write-Debug loo_Mime.LastErrorText destroy loo_Mime return end if Write-Debug "---- MIME structure ----" Write-Debug loo_Mime.GetStructure("text") Write-Debug "------------------------" loo_Email = create oleobject // Use "Chilkat_9_5_0.Email" for versions of Chilkat < 10.0.0 li_rc = loo_Email.ConnectToNewObject("Chilkat.Email") li_Success = loo_Email.LoadEml(ls_EmlPath) // Was this a signed and/or encrypted email? // If so, then loading the .eml automatically unwraps // (i.e. verifies signatures and decrypts) and the resultant // email is what existed prior to signing/encrypting. Write-Debug "Email was Signed: " + string(loo_Email.ReceivedSigned) Write-Debug "Email was Encrypted: " + string(loo_Email.ReceivedEncrypted) if loo_Email.ReceivedSigned = 1 then Write-Debug "Signature(s) valid = " + string(loo_Email.SignaturesValid) end if if loo_Email.ReceivedEncrypted = 1 then Write-Debug "Decrypted successfully = " + string(loo_Email.Decrypted) end if i = 0 li_NumAttach = loo_Email.NumAttachments Write-Debug "Number of attachments = " + string(li_NumAttach) do while i < li_NumAttach Write-Debug "---- Attachment " + string(i) // Examine the filename (if any) Write-Debug "filename: " + loo_Email.GetAttachmentFilename(i) // Examine the content-ID (if any) Write-Debug "Content-ID: " + loo_Email.GetAttachmentContentID(i) // Examine the content-type Write-Debug "Content-Type: " + loo_Email.GetAttachmentContentType(i) // Examine the content-disposition Write-Debug "Content-Disposition" + loo_Email.GetAttachmentHeader(i,"content-disposition") // Examine the attachment size: Write-Debug "Size (in bytes) of the attachment: " + string(loo_Email.GetAttachmentSize(i)) i = i + 1 loop Write-Debug "--" // Now for the related items. // Note: A MIME sub-part can potentially be both a related item AND an attachment. // The typical case is when the item is contained under the multipart/related enclosure and // the item also has a "Content-Disposition" header indicating "attachment". // The location within multipart/related makes it a "related item", yet the Content-Disposition can also make it semantically an attachment. // Related items and attachments are not necessarily mutually exclusive. li_NumRelated = loo_Email.NumRelatedItems Write-Debug "Number of related items = " + string(li_NumRelated) i = 0 do while i < li_NumRelated Write-Debug "---- Related Item " + string(i) // Examine the filename (if any) Write-Debug "filename: " + loo_Email.GetRelatedFilename(i) // Examine the content-ID (if any) Write-Debug "Content-ID: " + loo_Email.GetRelatedContentID(i) // Examine the content-type Write-Debug "Content-Type: " + loo_Email.GetRelatedContentType(i) // Examine the content-location (if any) Write-Debug "Content-Location" + loo_Email.GetRelatedContentLocation(i) i = i + 1 loop // The email could also have attached messages. // An attached message is another email that was attached to this email. li_NumAttachedMessages = loo_Email.NumAttachedMessages Write-Debug "Number of attached messages = " + string(li_NumAttachedMessages) i = 0 do while i < li_NumAttachedMessages Write-Debug "---- Attached message " + string(i) // Examine the attached email loo_Em = loo_Email.GetAttachedMessage(i) Write-Debug "from: " + loo_Em.From Write-Debug "subject: " + loo_Em.Subject destroy loo_Em i = i + 1 loop // An email could also be a multipart/report email. // This is a DSN (Delivery Status Notification) // The NumReports property indicates how many "reports" exist. li_NumReports = loo_Email.NumReports Write-Debug "Number of reports = " + string(li_NumReports) i = 0 do while i < li_NumReports Write-Debug "---- Report " + string(i) // Get the raw report data... Write-Debug loo_Email.GetReport(i) i = i + 1 loop // If the email is a multipart/report, then the information // from the message/delivery-status part of the email can be retrieved: if loo_Email.IsMultipartReport() = 1 then Write-Debug "--- Delivery Status Information:" Write-Debug "Status: " + loo_Email.GetDeliveryStatusInfo("Status") Write-Debug "Action: " + loo_Email.GetDeliveryStatusInfo("Action") Write-Debug "Reporting-MTA: " + loo_Email.GetDeliveryStatusInfo("Reporting-MTA") loo_Sa = loo_Email.GetDsnFinalRecipients() li_NumFinalRecipients = loo_Sa.Count i = 0 do while i < li_NumFinalRecipients Write-Debug "final recipient: " + loo_Sa.GetString(i) i = i + 1 loop destroy loo_Sa end if destroy loo_Mime destroy loo_Email |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.