Platforms to show: All Mac Windows Linux Cross-Platform

/CURL/Google Mail/Send email for google mail


Required plugins for this example: MBS CURL Plugin, MBS Main Plugin, MBS Images Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /CURL/Google Mail/Send email for google mail

This example is the version from Wed, 12th Oct 2021.

Project "Send email for google mail.xojo_binary_project"
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 // clear last one 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 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 email.UseSSL = true 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://mail.candelatech.com/INBOX/;uid=1 * Download all email for this user with IMAP: imap://mail.candelatech.com/ * Download all email in INBOX for this user with IMAP: imap://mail.candelatech.com/INBOX?ALL * Download all email in INBOX with POP3: pop3://mail.candelatech.com/ * Send email with SSL security using SMTP: smtps://mail.candelatech.com
Property Email As CURLEmailMBS
Property d As UploadCURL
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 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:

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


The biggest plugin in space...