Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

/CURL/Send Email/Send email
Function:
Required plugins for this example: MBS CURL Plugin, MBS Images Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /CURL/Send Email/Send email
This example is the version from Mon, 12th Mar 2017.
Project "Send email.rbp"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() Upload End EventHandler
End Control
Control Result Inherits Label
ControlInstance Result Inherits Label
End Control
Control Server Inherits TextField
ControlInstance Server Inherits TextField
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control Username Inherits TextField
ControlInstance Username Inherits TextField
End Control
Control Passwort Inherits TextField
ControlInstance Passwort Inherits TextField
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control content Inherits TextArea
ControlInstance content Inherits TextArea
End Control
Control ToEmail Inherits TextField
ControlInstance ToEmail Inherits TextField
End Control
Control StaticText4 Inherits Label
ControlInstance StaticText4 Inherits Label
End Control
Control FromEmail Inherits TextField
ControlInstance FromEmail Inherits TextField
End Control
Control StaticText5 Inherits Label
ControlInstance StaticText5 Inherits Label
End Control
Control StaticText6 Inherits Label
ControlInstance StaticText6 Inherits Label
End Control
Control Subject Inherits TextField
ControlInstance Subject Inherits TextField
End Control
Control Thread1 Inherits Thread
ControlInstance Thread1 Inherits Thread
EventHandler Sub Run() DoUpload End EventHandler
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() // update progress label if d<>Nil then if d.ProgressMessage<>"" then result.Text = d.ProgressMessage d.ProgressMessage = "" end if end if End EventHandler
End Control
Control FromName Inherits TextField
ControlInstance FromName Inherits TextField
End Control
Control ToName Inherits TextField
ControlInstance ToName Inherits TextField
End Control
Private Sub DoUpload() dim e as integer d = nil // close last transfer d = new UploadCURL if d.SetupEmail(email) then // ok else dim ee as integer = d.Lasterror Break // problem? end if // this is the file content here: d.YieldTime = true d.OptionVerbose = true d.CollectOutputData = true d.CollectDebugData = true // add this to use TLS ' d.OptionFTPSSL = 3 e=d.Perform if e = 0 then d.ProgressMessage = "Result: OK" else d.ProgressMessage = "Result: "+str(e) end if End Sub
Sub Upload() // we store stuff in variables here to avoid the ThreadAccessingUIException email = new CURLEmailMBS email.SetFrom FromEmail.Text, FromName.Text email.AddTo ToEmail.Text, ToName.text email.SMTPUsername = Username.Text email.SMTPServer = server.Text email.SMTPPassword = Passwort.Text email.Subject = Subject.Text email.PlainText = content.text dim pic as Picture = LogoMBS(500) dim jpegData as string = PictureToJPEGStringMBS(pic, 80) email.AddAttachment jpegData, "mbs.jpg", "image/jpeg" Thread1.run End Sub
Note "About"
* Download a specific email id with IMAP: imap://user:password mail.candelatech.com/INBOX/;uid=1 * Download all email for this user with IMAP: imap://user:password mail.candelatech.com/ * Download all email in INBOX for this user with IMAP: imap://user:password mail.candelatech.com/INBOX?ALL * Download all email in INBOX with POP3: pop3://user:password mail.candelatech.com/ * Send email with SSL security using SMTP: smtps://user:password mail.candelatech.com
Property Email As CURLEmailMBS
Property d As UploadCURL
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 UploadCURL 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 ultotal=0 then ProgressMessage = "Uploading..." else ProgressMessage = "Uploading "+Format(ulnow/ultotal,"-0%")+" "+stR(ulnow)+" of "+str(ultotal) end if End EventHandler
Sub Constructor() dim f as FolderItem = SpecialFolder.Desktop.Child("test.log") t = TextOutputStream.Append(f) End Sub
Property ProgressMessage As string
Property Private t As TextOutputStream
End Class
End Project

See also:

Feedback, Comments & Corrections

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




Links
MBS Xojo blog