Platforms to show: All Mac Windows Linux Cross-Platform

/CURL/Send Email/Send email in web


Required plugins for this example: MBS CURL 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 in web

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

Project "Send email in web.xojo_binary_project"
Class App Inherits WebApplication
End Class
Class Session Inherits WebSession
Const ErrorDialogCancel = "Do Not Send"
Const ErrorDialogMessage = "This application has encountered an error and cannot continue."
Const ErrorDialogQuestion = "Please describe what you were doing right before the error occurred:"
Const ErrorDialogSubmit = "Send"
Const ErrorThankYou = "Thank You"
Const ErrorThankYouMessage = "Your feedback helps us make improvements."
Const NoJavascriptInstructions = "To turn Javascript on, please refer to your browser settings window."
Const NoJavascriptMessage = "Javascript must be enabled to access this page."
End Class
Class WebPage1 Inherits WebPage
Control Label1 Inherits WebLabel
ControlInstance Label1 Inherits WebLabel
End Control
Control Server Inherits WebTextField
ControlInstance Server Inherits WebTextField
End Control
Control Label2 Inherits WebLabel
ControlInstance Label2 Inherits WebLabel
End Control
Control Username Inherits WebTextField
ControlInstance Username Inherits WebTextField
End Control
Control Label3 Inherits WebLabel
ControlInstance Label3 Inherits WebLabel
End Control
Control Passwort Inherits WebTextField
ControlInstance Passwort Inherits WebTextField
End Control
Control Label4 Inherits WebLabel
ControlInstance Label4 Inherits WebLabel
End Control
Control ToEmail Inherits WebTextField
ControlInstance ToEmail Inherits WebTextField
End Control
Control Label5 Inherits WebLabel
ControlInstance Label5 Inherits WebLabel
End Control
Control FromEmail Inherits WebTextField
ControlInstance FromEmail Inherits WebTextField
End Control
Control Label6 Inherits WebLabel
ControlInstance Label6 Inherits WebLabel
End Control
Control Subject Inherits WebTextField
ControlInstance Subject Inherits WebTextField
End Control
Control ToName Inherits WebTextField
ControlInstance ToName Inherits WebTextField
End Control
Control FromName Inherits WebTextField
ControlInstance FromName Inherits WebTextField
End Control
Control content Inherits WebTextArea
ControlInstance content Inherits WebTextArea
End Control
Control SendButton Inherits WebButton
ControlInstance SendButton Inherits WebButton
EventHandler Sub Pressed() SendEmail 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 Thread1 Inherits Thread
ControlInstance Thread1 Inherits Thread
EventHandler Sub Run() 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.CollectDebugMessages = 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 Dim d As String = d.DebugMessages If d.Encoding = Nil Then d = DefineEncoding(d, encodings.ISOLatin1) End If ErrorLog.Text = d End EventHandler
End Control
Control Result Inherits WebLabel
ControlInstance Result Inherits WebLabel
End Control
Control ErrorLog Inherits WebTextArea
ControlInstance ErrorLog Inherits WebTextArea
End Control
Sub SendEmail() // 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 = pic.GetData(pic.FormatJPEG, pic.QualityHigh) email.AddAttachment jpegData, "mbs.jpg", "image/jpeg" Thread1.run End Sub
Property Email As CURLEmailMBS
Property d As UploadCURL
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
Sign
End Sign
End Project

See also:

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


The biggest plugin in space...