PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WD12] Client PC sending emails...
[WD12] Client PC sending emails...
Iniciado por guest, 10,feb. 2011 08:37 - 26 respuestas
Publicado el 10,febrero 2011 - 08:37
Hi guys,
Just require a bit of an insight into how to look at incoming emails and send emails from a WD app when it's a client PC on a network - how does this work?
I'm not that well up on email configuration on a network - in fact, I'm not even that sure how to ask the question that well... :confused:
Ultimately (quite soon), my customer will have several pc (clients) on his network, each with my app installed and each sharing the data via a shared folder. He's already expressed an interest in being able to browse and find a product then show a customer some associated photos (the app already does this), but at the press of a button, he'd like to be able to create an email and automatically attach said photos and send to the customer or it may be that the customer is on the phone and he wants to send the email.
My question is, what is required in doing this? I presume I'll use the Email variable type to set up the email properties and the email attachment function to attach photos, but what configuration does WD expect? Do you guys use office based email servers or email routing software?
Also, at some point in the future I want my app to be able to monitor incoming emails for (say) key words in the subject line for example and maybe pop-up some kind of notification.
Not looking for something too in depth at this point - just a discussion... :spos:
Publicado el 10,febrero 2011 - 08:37
In the help it's referenced that you can send/receive emails thru outlook, i don't know it it works because i never used it.
I always use EmailStartPOP3Session to read emails and EmailStartSMTPSession to send emails, my email server supports SMTP/POP3 connections, almost all emails server can work this ways.
for both ways you have to use the email structure.
If you want to format the email with picture and so on it's better to use the email.HTML
http://doc.windev.com/en-US/…
To read emails:
EmailStartPOP3Session
EMailReadFirst
While Email.Out = False
...
EmailReadNext
END
To send emails:
EmailStartSMTPSession
Email.Sender = "xxx@yyy.com"
...
EMailSendMessage
Publicado el 10,febrero 2011 - 08:38
Hello Darren
Never bothered to find out. I just click on send and the email goes out - I think its magic!
Regards
Al
Publicado el 10,febrero 2011 - 08:38
Thanks for your suggestions guys :spos:
Which mail servers do you use? Is it Window$ based?
Publicado el 10,febrero 2011 - 08:38
Hello Darren
We use both smtp and Outllook sessions to send emails, the the main difference is that smtp will require you to collect the username and password from each user on the LAN where the Outlook sessions get all that by opening the Outlook profile. We found the various Windev email examples to be very helpful in building our code.
Another option in terms of sending data is to put it in a report and email the report as a pdf from the report writer.
Regards
Al
Publicado el 10,febrero 2011 - 08:39
You don't have to worry what/where is the mail server, you only have to worry about wich protocol it supports and are running.
POP3/SMTP are the most used ones.
Piet sugestion is a very nice one, with that kind of information you wont be in trouble if the configuration changes.
For the reading emails part you have to think a little bit more about what you need. If it's only for one specific mail box use the same technique sugested by Piet for the POP3 parameters, if it's for more than one you have to choose a solution to know all the users/passwords.
Publicado el 10,febrero 2011 - 08:39
Hi Darren,
You may want to let them fill out their smtp server data themselves. (Or not if you want them to need you to make an update if they switch provider or reconfigure their own mail server)
Create some way of storing these variables in an ini file or in their own database and create an entry form screen for these settings.
What you need are:
-Server ip-address or something like smtp.myprovider.com
-Server port (optional)
-Server Username (optional)
-Server password (optional)
-Check box if secure connection
-Reply email address(general or per user)
Then to open the email session you first read the connection parameters and open the session:
IF bSecureConnection THEN
gbSessionOpen=EmailStartSMTPSession(sUser, sPassWord,sSmtp,nPort,False,emailOptionSecuredTLS)
ELSE
gbSessionOpen=EmailStartSMTPSession(sUser,sPassWord,sSmtp)
END
There are some nice mailing examples that are almost ready to use.
Regards,
Piet
Publicado el 10,febrero 2011 - 08:39
Cheers Piet... :spos: thanks for reminding me - I already have a "System Settings" maintenance window. I'd add it to that window/data file. They already have the ability to amend various things such as their remote (ISP) FTP settings for example.
Publicado el 10,febrero 2011 - 08:39
Thanks Paulo - the "reading email" one may go on "hold" for a while or at least onto an ever increasing "to do" list ;)
...but at least this small discussion has raised some interesting issues and things to look out for...
Cheers guys... :spos:
Publicado el 20,febrero 2011 - 23:46
Okay, tried to create a quick test and all seems good but I get the following error message at the EmailSendMessage:
Dump Error of module .
- WL Call:
Processing , line , thread
FUNCTION , syntax #
- Level: Non-fatal Error (EL_ONRETURN)
- Error Code: 100083
- WD55 Error Code: 0
- No system Error code
- No system Error Message
- What happened?
Unable to send Message.
Check the recipient addresses as well as your account settings (sender Address).
Failure may be caused by a technical problem.
Four successive attempts have been made. Problem Details:
- First Attempt:
Failure sending recipients.
Last SMTP Server Response:
- Second Attempt:
Content of Email.Sender not recognized by server. Transaction denied.
Last SMTP Server Response:
essai2
- Third Attempt:
Content of Email.Sender not recognized by server. Transaction denied.
Last SMTP Server Response:
- Fourth Attempt:
Content of Email.Sender not recognized by server. Transaction denied.
Last SMTP Server Response:

- Debug Information:
FONCTION (10,14)
- Attached Information:
EIT_PILEWL :
Click WPB_Send (WDWIN_SendEmail.WPB_Send), ligne 26
EIT_COMPOSANT :
EIT_DATEHEURE : 20/02/2011 19:56:12
- No identifier IN .err

I'm not sure why the EmailStartSession seems to work and the Send doesn't :confused: ...doesn't the start initialise the connection???
I've debugged and the variables seem to be defined correctly. The settings are the same as I use in Outlook and that works fine... :confused: Is there anything anyone can see that I may be doing wrongly?
// Start the session
EmailStartSession(gwinvsEmailUsername , gwinvsEmailPassword , gwinvsPOP3Server , gwinvsSMTPSever)
IF ErrorOccurred THEN
Error("Unable to connect", ErrorInfo(errSummary))
RETURN
END
// Insert your process here
// Initializes the components of the email
Email.Sender = gwinvsSMTPSenderAddress// The sender
Email.Recipient[1] = WEDIT_CEmail// The recipient
Email.NbRecipient = 1// The number of recipients
Email.Subject = WEDIT_CSubjectLine// The subject
Email.Message = WEDIT_CMessageText// The body of the message
//Attachments
glocaliCounter is int = 0
FOR EACH SELECTED ROW OF WLV_Product_Photos
glocaliCounter ++
Email.Attach[glocaliCounter]=WLV_Product_Photos..DisplayedValue
Email.NbAttach=glocaliCounter
END
// Sends the email
IF EmailSendMessage(gwinvsEmailUsername) = False THEN
Error()
END
// Close the session
EmailCloseSession(gwinvsEmailUsername)
Publicado el 21,febrero 2011 - 07:05
Hello Darren
It looks like the problem could be in the attachments. You could comment out the attachment code temporarily and see if that fixes it.
One thing to check is the actual number of attachments with the counter. If the WLV_Product_Photos..DisplayedValue is blank but the NbAttach counter is always incremented and these get out of synch because of a blank attachment you will get an error.
You may also get an error if the attachment does not have a full and correct path.

Regards
Al
Publicado el 21,febrero 2011 - 11:16
Hi Darren,
For some reason my provider blocks the sending of emails with a "noreply" sender.
Perhaps your provider has the same policy.
Regards,
Piet
Publicado el 21,febrero 2011 - 11:44
Hi Al / Piet,
I'm pretty sure the attachment variables are okay - but what do I know? ;)
I've taken it through debug and the path is okay - it's a path to an image that the rest of my app uses and it works there and the count matches the number of attachments - it's just 1 for my initial test. I'll tighten up the checking when I get the basics working [[5]] :spos:
Piet, I'll try your suggestion - that could be the answer, but I'm not sure. The above code is generated by the wizard and I added the attachement bit. I presume there's a NoReply option? I'll take a look at the Help... [[5]]
Publicado el 21,febrero 2011 - 14:10
Hello Darren
The command you are using to start the session is one that starts a pop3/smtp session without specifically indicating which one. When we send emails we explicitly start the exact type of session using either : EmailStartOutlookSession or EmailStartSMTPSession.
As you are attempting to start a pop3 session why not try the specific command EmailStartPop3Session. There may be some subtle differences between the specific type of named sessions and the generic one ?
Edit: just realised that the named pop3 session is for reading not sending but can you try the smtp session ?
Regards
Al
Publicado el 21,febrero 2011 - 14:10
Hi Darren,
No, what I mean is that if I use noreply@vzs.nl as return address, the smtp server refuses the email. If I use any other existing email address (even from another domain) it is sent. This is not anything I can fix in Windev, it's just an anti-spam measure I suppose.
I agree with Al, for sending email I use EmailStartsmtpSession too.
Regards, Piet
Publicado el 21,febrero 2011 - 14:10
Al / Piet,
Okay Piet, I'm with you, but no, I don't use a Noreply email address when sending.
Yes, I posted the above code as I was getting the same failure when using the wizard to create an EmailStartsmtpSession as well :confused:
I've got a feeling that this is probably going to be an issue with my ISP's SMTP server implementation - possibly around security (I'm guessing?) ...although I'm not sure how I can fix it if it is:eek:
I'll try an EmailStartsmtpSession again so that I'm sure it's an SMTP issue and see where I go from there... [[5]]
I'm also wondering if there's a log on my ISP's server I could see so that I know the precise error it's generating, and not just the vague "Check the recipient addresses as well as your account settings (sender address)" message?
Cheers... :spos:
Publicado el 21,febrero 2011 - 17:02
Darren
The error you received from the SMTP server "550 Relaying denied. Proper authentication required" is just that - the server does not know who you are / or relaying is specifically denied.
The subsequent errors are just that the server has denied your further attempts.
Unless you are local to the SMTP server (same subnet) then open relaying should be blocked.
Is the SMTP server local or remote?
Do you have access to the SMTP server config?
Fill me in a little more and I'll try to help.
Publicado el 21,febrero 2011 - 17:40
Hi Eric,
No, I don't really have much config access, in fact next to none. It's a simple ISP config, so it's remote.
I'm (probably or definately!) being a bit dumb, but if I can send an email from Outlook or a.n.other email client, why can I not send the same email from within WD (as long as I specifiy the same credentials)? What do email clients do differently to what I'm attempting in WD?
Cheers...
Publicado el 21,febrero 2011 - 18:29
Darren
I'm sure if you look over the config of your email client (outlook etc) you'll find the account is set to authenticate before sending "pop before send".
You can do this in windev too but you can't do it with EmailStartSession you will have to start a POP3 session (EmailStartPOP3Session) and then a SMTP session at the same time (EmailStartSMTPSession).
Publicado el 21,febrero 2011 - 18:44
Thanks Eric - I'll check out my outlook settings and give your suggestion a try... :spos: [[5]]
Publicado el 22,febrero 2011 - 14:41
Hi guys,
Managed to get it working - starting a POP session followed by an SMTP session seemed to do the trick! [[5]]
Outlook had a setting that said something like; my outgoing email requires authentication, but with this option checked or un-checked it still worked :confused: ...so it's working, but I'm always a bit unsure when things work and I don't totally understand why:confused:
Anyhow - it's working and that's the main thing - thanks everyone for their help on this... :spos:
Publicado el 03,marzo 2011 - 23:38
Hi guys,
When I said that I managed to get it working - that was in test mode!
When I installed it in my live/test environment, it fails, so I suppose it's back to my original question - how does this here email stuff work??? ;)
But seriously - when I run in WD Test mode - it sends the email okay, but when I run in my live/test environment, on 1 PC it hangs (this in the PC that runs okay in WD test mode), and when I run on a different live/test PC I get the following error which shows that it's not picking up email credentials:
Dump Error of module .
- WL Call:
Processing , line , thread
FUNCTION , syntax #
- Level: Non-fatal Error (EL_ONRETURN)
- Error Code: 100035
- WD55 Error Code: 0
- No system Error code
- No system Error Message
- What happened?
POP3 Session: connection failed. No server response.
Last POP3 Server Response:

- Debug Information:
FONCTION (10,69)
- Attached Information:
EIT_PILEWL :
Click WPB_Send (WDWIN_SendEmail.WPB_Send), ligne 12
Click WIMG_ProductOption11 (WDWIN_MainMenu.WSIDEB_MenuCategories.WIMG_ProductOption11), ligne 1
EIT_COMPOSANT :
EIT_DATEHEURE : 03/03/2011 19:12:26
- No identifier IN .err

I'm confused why it work when running my app in WD test mode, but not when I run it as an installed app on the same PC? :confused:
Publicado el 04,marzo 2011 - 07:52
Darren
From your error:
Publicado el 04,marzo 2011 - 07:53
Hi Eric,
Checked and the WD120COM.dll is installed with my app and the framework is installed also.
The data is coming from a DB file - but your statement prompted me to double check the data - and one of the values was incorrect, but after correcting, both PCs fail in the same way and my app no longer hangs - both PCs come back with the following message (I've inserted the nnn's):
Dump Error of module .
- WL Call:
Processing , line , thread
FUNCTION , syntax #
- Level: Non-fatal Error (EL_ONRETURN)
- Error Code: 100042
- WD55 Error Code: 0
- No system Error code
- No system Error Message
- What happened?
SMTP Session: connection failed. No server response.
Last SMTP Server Response:

- Debug Information:
FONCTION (10,70)
- Attached Information:
EIT_PILEWL :
Click WPB_Send (WDWIN_SendEmail.WPB_Send), ligne 24
Click WPB_Email_Photos (WDWIN_Product_Photo_Maint.WPB_Email_Photos), ligne 2
Click WPB_Photos (WDWIN_Product_Maint.WPB_Photos), ligne 2
Click WIMG_ProductOption1 (WDWIN_MainMenu.WSIDEB_MenuCategories.WIMG_ProductOption1), ligne 1
EIT_COMPOSANT :
EIT_DATEHEURE : 03/03/2011 23:20:18
- No identifier IN .err

And the code looks like this:
// Do POP first...
EmailStartPOP3Session(gwinvsEmailUsername,gwinvsEmailPassword,gwinvsPOP3Server)
IF ErrorOccurred THEN
Open(WDWIN_DisplayErrorText,ErrorInfo(errFullDetails))
RETURN
END
// Next do SMTP...
EmailStartSMTPSession(gwinvsEmailUsername,gwinvsEmailPassword,gwinvsSMTPSever)
IF ErrorOccurred THEN
Open(WDWIN_DisplayErrorText,ErrorInfo(errFullDetails))
RETURN
END
Publicado el 04,marzo 2011 - 16:20
Often the following helps:
Use the default secured SMTP port 587 instead of the standard SMTP port 25 which is blocked by most providers for requests coming from outside of their network.
Also authenticate with a username and password. Providers will rarely allow unauthenticated (user + password) and unsecured SMTP (port 587) over their servers.
Just my 2 cents,
Peter H.
Publicado el 04,marzo 2011 - 16:20
Thanks Peter...
I thought I was authenticating with Username / Password and the only difference between this working and not working is the mode that I run it in :confused: It works in WD test mode and doesn't work from an installed app :confused:
Miembro registrado
71 mensajes
Publicado el 13,abril 2016 - 09:13
Hello DarrenF,

I probably have similar problém. I would like to ask you if you solved it somehow.

Thank you

Regards

Petr