E-mail with 4.0
E-mail with 4.0
Hello. Does anyone have some code to send e-mail from PB 4.0? I've searched the forums but haven't found much results.
Thanks in advance!
Thanks in advance!
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
Hi!
Look an http://people.freenet.de/gnozal/
2 libraries for PB4 : POP3 and SMTP can resolve your problem
tom
Look an http://people.freenet.de/gnozal/
2 libraries for PB4 : POP3 and SMTP can resolve your problem
tom
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Yes, they will be released when PB 4 final and Tailbite for PB4 are released.mskuma wrote:Seems like the links to the PB4 version are broken (due to in-progress?).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Re: E-mail with 4.0
> Does anyone have some code to send e-mail from PB 4.0?
Here's something I posted ages ago that I updated for v4.00, but it doesn't
support attachments. But for quick sending of e-mails, it works great!
Not mine but I cleaned it up and streamlined it into a neat little code block.
My original post was here: http://www.purebasic.fr/english/viewtopic.php?t=3805
> I've searched the forums but haven't found much results.
There are some links in the Coding Questions FAQ.
(Edited to make it even smaller, and removed a global variable).
Here's something I posted ages ago that I updated for v4.00, but it doesn't
support attachments. But for quick sending of e-mails, it works great!

Not mine but I cleaned it up and streamlined it into a neat little code block.
My original post was here: http://www.purebasic.fr/english/viewtopic.php?t=3805
> I've searched the forums but haven't found much results.
There are some links in the Coding Questions FAQ.

Code: Select all
Global MailID
Procedure MailDataSend(msg$)
SendNetworkData(MailID,@msg$,Len(msg$))
EndProcedure
Procedure.s MailResponse()
a$=Space(9999) : ReceiveNetworkData(MailID,@a$,9999)
ProcedureReturn Left(a$,3)
EndProcedure
Procedure MailSend(ms_server$,ms_port$,ms_recipient$,ms_subject$,ms_body$,ms_from$)
If InitNetwork()
MailID=OpenNetworkConnection(ms_server$,Val(ms_port$))
If MailID
If MailResponse()="220"
MailDataSend("HELO Mailer"+#CRLF$)
If MailResponse()="250"
MailDataSend("MAIL FROM: <"+ms_from$+">"+#CRLF$)
If MailResponse()="250"
MailDataSend("RCPT TO: <"+ms_recipient$+">"+#CRLF$)
If MailResponse()="250"
MailDataSend("DATA"+#CRLF$)
If MailResponse()="354"
MailDataSend("Date: "+#CRLF$)
MailDataSend("From: "+ms_from$+#CRLF$)
MailDataSend("To: "+ms_recipient$+#CRLF$)
MailDataSend("Subject: "+ms_subject$+#CRLF$)
MailDataSend(ms_body$) : MailDataSend(""+#CRLF$) : MailDataSend("."+#CRLF$)
If MailResponse()="250" : MailDataSend("QUIT"+#CRLF$) : result=1 : EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
CloseNetworkConnection(MailID)
EndIf
EndIf
ProcedureReturn result
EndProcedure
MailSend("mail.isp.com.au","25","to@address.com","SubjectGoesHere","BodyGoesHere","from@address.com")
Last edited by PB on Mon Mar 20, 2006 9:22 pm, edited 3 times in total.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
> Seems to work great EXCEPT my body text isn't coming through in the
> email ... any ideas?
Don't know, works great here... what sort of body text are you sending?
Can you post a snippet to show what fails? I've yet to have it fail on me.
> Also, you wouldn't happen to have similarly straightforward sample code
> for POP3, would ya?
Not yet.
> email ... any ideas?
Don't know, works great here... what sort of body text are you sending?
Can you post a snippet to show what fails? I've yet to have it fail on me.
> Also, you wouldn't happen to have similarly straightforward sample code
> for POP3, would ya?
Not yet.

I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
I'm using the exact code you posted here, except with my ISP's smtp server and my email addresses.PB wrote:... Can you post a snippet to show what fails? I've yet to have it fail on me.
Nothing is really failing, the email is successfully sent and delivered, just when the email is delivered, there's no body ...
I'm using Thunderbird, is this working for everyone else using Thunderbird?