PowerBuilder
PowerBuilder
Create an IMAP Mailbox
See more IMAP Examples
Demonstrates the Chilkat Imap.CreateMailbox method, which creates a mailbox on the IMAP server. When creating nested mailboxes, use the server's hierarchy delimiter reported in the SeparatorChar property. This example creates a mailbox named Archive2026.
Background: IMAP folders form a hierarchy, and the character that separates levels varies by server — commonly
/ or .. To create a sub-folder you build the path with that delimiter (for example Archive/2026), which is why you should read SeparatorChar rather than assume one. Creating mailboxes lets an application organize mail into folders programmatically, such as filing messages by year or project.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Imap
li_Success = 0
// Demonstrates the Imap.CreateMailbox method, which creates a mailbox on the IMAP server.
// Use the server's hierarchy delimiter (the SeparatorChar property) when creating nested
// mailboxes.
loo_Imap = create oleobject
li_rc = loo_Imap.ConnectToNewObject("Chilkat.Imap")
if li_rc < 0 then
destroy loo_Imap
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Imap.Ssl = 1
loo_Imap.Port = 993
li_Success = loo_Imap.Connect("imap.example.com")
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
li_Success = loo_Imap.Login("user@example.com","myPassword")
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
// Create a new mailbox (folder) on the server.
li_Success = loo_Imap.CreateMailbox("Archive2026")
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
Write-Debug "Mailbox created."
li_Success = loo_Imap.Disconnect()
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
destroy loo_Imap