Platforms to show: All Mac Windows Linux Cross-Platform
/CURL/Receive Email/CURLS pop3 email download
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 pop3 email download
This example is the version from Wed, 7th Jan 2014.
Project "CURLS pop3 email download.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
Prepare
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 MyThread Inherits Thread
ControlInstance MyThread Inherits Thread
EventHandler Sub Run()
DoDownload
End EventHandler
End Control
Control EmailIndex Inherits TextField
ControlInstance EmailIndex Inherits TextField
End Control
Control StaticText4 Inherits Label
ControlInstance StaticText4 Inherits Label
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control content Inherits TextArea
ControlInstance content Inherits TextArea
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action()
if curl.message<>"" then
ResultText.Text = curl.Message
curl.Message = ""
end if
if TransferDone then
AfterTransfer
me.Mode = 0
end if
End EventHandler
End Control
Private Sub AfterTransfer()
ResultText.text="Result: "+str(ErrorCode)
if ErrorCode = 56 then
ResultText.text = ResultText.text + " no email"
end if
if ErrorCode = 0 then
dim em as new EmailMessage
em.Source = curl.OutputData
content.Text = em.BodyPlainText
dim ed as EmailHeaders = em.Headers
dim c as integer = ed.Count-1
for i as integer = 0 to c
List.AddRow ed.Name(i)
List.Cell(List.LastIndex,1)=ed.Value(ed.Name(i))
next
end if
End Sub
Private Sub DoDownload()
ErrorCode = curl.Perform
TransferDone = true
End Sub
Sub Prepare()
List.DeleteAllRows
content.text = ""
TransferDone = false
curl = new DownloadCURL
curl.CollectOutputData = true
curl.OptionURL = "pop3://"+Server.Text+"/"+EmailIndex.text
curl.OptionUsername = Username.Text
curl.OptionPassword = Passwort.Text
curl.YieldTime = true
curl.OptionVerbose = true
// start thread
MyThread.run
timer1.Mode = 2
End Sub
Property Private ErrorCode As integer
Property TransferDone As Boolean
Property Private curl As DownloadCURL
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
Class DownloadCURL Inherits CURLSMBS
EventHandler Sub DebugMessage(infotype as integer, data as string)
t.WriteLine data
t.Flush
End EventHandler
EventHandler Function Progress(dltotal as double, dlnow as double, ultotal as double, ulnow 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.