Platforms to show: All Mac Windows Linux Cross-Platform

/CURL/Send Email/Send Email in Background async


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/Send Email/Send Email in Background async

This example is the version from Wed, 3rd Jan 2023.

Project "Send Email in Background async.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim lines() as string lines.Append "Hello," lines.Append "" lines.Append "Happy new year!" lines.Append "" lines.Append "Sincerly" lines.Append "Planetum Server" lines.Append "" // fill in something useful dim email as new CURLEmailMBS email.SetFrom "xxx@monkeybreadsoftware.eu", "Planetum Server" email.AddTo "xxx@xxx.xxx", "User" email.SMTPUsername = "xxx@monkeybreadsoftware.eu" email.SMTPServer = "xxxxx" email.SMTPPassword = "xxxxxx" email.Subject = "New Year Greetings" email.PlainText = Join(lines, EndOfLine) dim c as new CURLSMBS if c.SetupEmail(email) then // set options you may need c.OptionVerbose = true c.CollectDebugMessages = true c.CollectOutputData = true c.OptionConnectionTimeout = 5 // add for queue to send asyncronously CURLSMulti.add c end if End EventHandler
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class CURLTImer Inherits Timer
EventHandler Sub Action() // do something in background m.Perform End EventHandler
Sub Constructor(m as CURLSMultiMBS) // one timer to do regulasrly the CURL transfers if something is on the todo list self.m = m period = 40 mode = 2 End Sub
Property m As CURLSMultiMBS
End Class
Class CURLSMulti Inherits CURLSMultiMBS
EventHandler Sub TransferFinished(curl as CURLSMBS, result as Integer, RemainingFinishedTransfers as Integer) #Pragma DisableBackgroundTasks true // write log in case of error if result <> 0 then dim f as FolderItem = SpecialFolder.Desktop.Child("curl.log") dim t as TextOutputStream = TextOutputStream.Append(f) dim d as string = curl.DebugMessages d = ReplaceLineEndings(d, EndOfLine) t.WriteLine d end if End EventHandler
Shared Sub Add(curl As CURLSMBS) if m = nil then // first m = new CURLSMulti t = new CURLTimer(m) end if if m.AddCURL(curl) then // ok else Break end if End Sub
Property Protected Shared m As CURLSMulti
Property Protected Shared t As CURLTImer
End Class
End Project

See also:

The items on this page are in the following plugins: MBS CURL Plugin.


The biggest plugin in space...