Platforms to show: All Mac Windows Linux Cross-Platform
/CURL/Receive Email/CURLS imap
Required plugins for this example: MBS CURL Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /CURL/Receive Email/CURLS imap
This example is the version from Wed, 3rd Jan 2023.
Project "CURLS imap.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
QueryList
End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control Server Inherits TextField
ControlInstance Server Inherits TextField
End Control
Control Username Inherits TextField
ControlInstance Username Inherits TextField
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control Passwort Inherits TextField
ControlInstance Passwort Inherits TextField
End Control
Control ResultText Inherits Label
ControlInstance ResultText Inherits Label
End Control
Control content Inherits TextArea
ControlInstance content Inherits TextArea
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub Change()
if me.ListIndex >= 0 then
content.text = ""
dim curl as new CURLSMBS
curl.CollectOutputData = true
curl.OptionURL = "imap://"+Server.Text+"/INBOX;UID="+me.Cell(me.ListIndex,0)
curl.OptionUsername = Username.Text
curl.OptionPassword = Passwort.Text
curl.OptionVerbose = true
curl.YieldTime = true
curl.CollectDebugMessages = true
curl.CollectOutputData = true
dim e as integer = curl.Perform
if e<>0 then
MsgBox "Error code: "+str(e)
else
dim content as string = curl.OutputData
if content.Encoding = nil then
content = DefineEncoding(content, encodings.ISOLatin1)
end if
self.content.text = ReplaceLineEndings(content, EndOfLine)
end if
dim s as string = curl.DebugMessages
if s.Encoding = nil then
s = DefineEncoding(s, encodings.ISOLatin1)
end if
s = ReplaceLineEndings(s, EndOfLine)
DebugText.Text = s
else
content.Text = ""
end if
End EventHandler
End Control
Control DebugText Inherits TextArea
ControlInstance DebugText Inherits TextArea
End Control
Sub QueryList()
List.DeleteAllRows
content.text = ""
dim curl as new CURLSMBS
curl.CollectOutputData = true
curl.OptionURL = "imap://"+Server.Text+"/INBOX"
curl.OptionUsername = Username.Text
curl.OptionPassword = Passwort.Text
curl.OptionCustomRequest = "FETCH 1:* FLAGS"
curl.OptionVerbose = true
curl.YieldTime = true
curl.CollectDebugMessages = true
curl.CollectOutputData = true
dim e as integer = curl.Perform
if e<>0 then
MsgBox "Error code: "+str(e)
else
dim content as string = curl.OutputData
if content.Encoding = nil then
content = DefineEncoding(content, encodings.ISOLatin1)
end if
content = ReplaceLineEndings(content, EndOfLine)
dim lines() as string = Split(content, EndOfLine)
for each line as string in lines
if NthField(line," ",1) = "*" then
List.addrow NthField(line," ",2)
end if
next
end if
dim s as string = curl.DebugMessages
if s.Encoding = nil then
s = DefineEncoding(s, encodings.ISOLatin1)
end if
s = ReplaceLineEndings(s, EndOfLine)
DebugText.Text = s
End Sub
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu5 = ""
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
MenuItem UntitledMenu4 = ""
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = ""
End MenuBar
Class App Inherits Application
End Class
Class DownloadCURL Inherits CURLSMBS
EventHandler Sub DebugMessage(infotype as integer, data as string, dataSize as Integer)
t.WriteLine data
t.Flush
End EventHandler
EventHandler Function Progress(dltotal as Int64, dlnow as Int64, ultotal as Int64, ulnow as Int64, percent as double) As boolean
if dltotal=0 then
Message = "Downloading..."
else
Message = "Downloading "+Format(dlnow/dltotal,"0%")
end if
Return false
End EventHandler
Sub Constructor()
dim f as FolderItem = SpecialFolder.Desktop.Child("test.log")
t = TextOutputStream.Create(f)
End Sub
Property Message As string
Property Private t As TextOutputStream
End Class
End Project
See also:
The items on this page are in the following plugins: MBS CURL Plugin.