Sample code for 30+ languages & platforms
PowerBuilder

Fetch a POP3 Message's Raw MIME by UIDL

See more POP3 Examples

Demonstrates the Chilkat MailMan.FetchMimeBd method, which fetches an email from the POP3 server by UIDL and stores the raw MIME source bytes in a BinData. Chilkat clears the BinData before downloading. This example fetches one message's MIME into a BinData.

Background: Sometimes you want the message exactly as it arrived — the raw MIME bytes — rather than a parsed Email object, for example to archive it verbatim as a .eml file, forward it untouched, or hash it. Fetching into a BinData preserves every byte precisely, without any parsing or re-encoding that could alter the original.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mailman
oleobject loo_BdMime

li_Success = 0

//  Demonstrates the MailMan.FetchMimeBd method, which fetches an email from the POP3 server
//  by UIDL and stores the raw MIME source bytes in a BinData.  Chilkat clears the BinData
//  before downloading.

loo_Mailman = create oleobject
li_rc = loo_Mailman.ConnectToNewObject("Chilkat.MailMan")
if li_rc < 0 then
    destroy loo_Mailman
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//  Configure the POP3 server connection.
loo_Mailman.MailHost = "pop.example.com"
loo_Mailman.MailPort = 995
loo_Mailman.PopSsl = 1
loo_Mailman.PopUsername = "user@example.com"
loo_Mailman.PopPassword = "myPassword"

//  Fetch the raw MIME of a specific message by UIDL into a BinData.
loo_BdMime = create oleobject
li_rc = loo_BdMime.ConnectToNewObject("Chilkat.BinData")

li_Success = loo_Mailman.FetchMimeBd("0000000123abcdef",loo_BdMime)
if li_Success = 0 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    destroy loo_BdMime
    return
end if

Write-Debug "MIME size (bytes) = " + string(loo_BdMime.NumBytes)

//  Note: Explicitly connecting/authenticating is optional.  Chilkat MailMan automatically
//  connects and authenticates -- using the property settings above -- whenever a server
//  operation requires it.  Calling the explicit connect/authenticate methods can still be
//  helpful to determine whether a failure occurs while connecting or while authenticating.


destroy loo_Mailman
destroy loo_BdMime