Send email from webapp that does not have a webpage

I have a webapp on my server that just sits and listens for requests from my mobile apps.
Now I would like for that webapp to send me an email when a specific request is made. How can I send an email if the webapp does not display a webpage? I do have MBS plugins if that helps.
Any hints at all would be helpful.
Thanks

Hi Gary, this is actually pretty simple. It’s almost easier to do than to explain, but I’ll give it a try!

I usually create a Module in my Web project and call it “Messenger”. I add a class and call it “MailSocket” as a subclass of SMTPSecureSocket.

If you are deploying on TargetXojoCloud then there is a simple call that opens a port on their system (I can paste that to you if you need it). Here’s the basic idea…

For testing create a method in your app somewhere, like this:

// Create EmailMessage
Var mail As New EmailMessage
mail.FromAddress = "John Doe <do_not_reply@somedomain.com>"
mail.AddRecipient("someemail@someotherdomain.com")
mail.Subject = "Hello it's my subject!"
mail.BodyHTML = Messenger.msg_template_GENERIC_html
mail.BodyPlainText = Messenger.msg_template_GENERIC_plaintext
mail.Headers.AddHeader("X-Mailer","if you want a header you can put on in")
Messenger.Outbox(mail)

Inside your Messenger.Outbox(msg as EmailMessage) looks like this:

EmailSocket = New MailSocket

// Connect to Server
EmailSocket.Address = "mail.yourmailserver.com"
EmailSocket.Port = 465
EmailSocket.ConnectionType = SMTPSecureSocket.TLSv11
EmailSocket.SMTPConnectionType = SMTPSecureSocket.SMTPConnectionTypes.SSLTLS
EmailSocket.SSLEnabled = True

EmailSocket.Username = "do_not_reply@somedomain.com"
EmailSocket.Password = "yourP4sswORdHere"

// Send it
EmailSocket.Messages.AddRow(msg)
EmailSocket.SendMail

That is great, I never thought about a module for this.
Thanks for the reply and I will add that to my Web app.