[Gambas-user] Sending E-Mail...

Willy Raets willy at ...2734...
Mon Mar 18 21:50:17 CET 2013


On Mon, 2013-03-18 at 18:55 +0000, Ru Vuott wrote:
> Hello,
> 
> I would like to point out what a forum member of "Gambas-it.org" wrote about the problem of sending email:
> 
> ********
> These days I tried the component gb.net.smtp with poor results, then I started to study and I made a small class to send mail with a Telnet terminal.
> 
> But I would like to know if the Socket of gambas could somehow replace Telnet to communicate with the SMTP server.
> 
>    220 posta.hextra.it Service ready
> 
> and then it seems to disconnect !!!
> 
> Have you had similar experiences ?
> 
> *********
> 
> Well, as we can help our friend?
> 
> Thanks
> 
> vuott
> 
What seems to be the problem as I have no trouble sending mail using
gb,net.smtp

This is an example directly from one of my projects.
Note that info is retrieved from setting on a mail preferences form
where user can set the values and they are saved as settings.

Nore: All settings are string values from settings file using
gb.settings.
Settings["mail/from"] = yourmail at ...3115...
Settings["mail/smtp"] = smtp.yourprovider.org
Settings["mail/port"] = 25

DefaultMail is a Public String variable I use to provide my own mail
address.
I use this routine for error trapping and having error info send back to
me automatically if Mail Preferences are set.

It works like a charm..

Private Sub SendMail(TextToSend As String, Subject As String)
  
  Dim hMail As New SmtpClient
  hMail.To.Add(DefaultMail)
  hMail.From = Settings["mail/from"]
  hMail.Host = Settings["mail/smtp"]
  hMail.Port = Settings["mail/port"]
  'If Settings["mail/tsl"] = -1 Then
  '  hMail.Encrypt = 2
  'Else
    hMail.Encrypt = 0
  'Endif
  hMail.Subject = Subject
  hMail.Add(TextToSend)
  hMail.Send
  MailSend = True

End

I commented out the encryption as I don't get it to work. But that is
not a Gambas problem as my regular (non Gambas mail client) can't send
SSL or TSL either.

Hope this can help your friend

-- 
Kind regards,

Willy (aka gbWilly)

http://gambasshowcase.org/
http://howtogambas.org
http://gambos.org








More information about the User mailing list