Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Store emails in MySql tables

Posted on 2012-04-11
9
Medium Priority
?
596 Views
Last Modified: 2012-04-14
In our application, written in VFP9, we would like to include a routine for store, in MySql tables, incoming and / or sent emails ( and then another routine to open these emails ).

Is that possible?

Translate from portuguese:

"Em nosso aplicativo, escrito em VFP9, gostaríamos de incluir uma rotina para armazenar, em tabelas MySql, emails recebidos e/ou enviados ( e, depois, outra rotina para abrir esses emails ).

Isto é possível? "
0
Comment
Question by:etm_wkl
9 Comments
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 37836013
Of course that is possible but why do you wish to reinvent the wheel?

I mean there are software to store emails and contents and they have quite a wide range of utilities to go with that.

You can use CDONTS to send emails. It needs to be configured on a server and FoxPro can communicate with it quite well.

http://fox.wikis.com/wc.dll?Wiki~CdoEmail

http://support.microsoft.com/kb/186204
http://www.w3schools.com/asp/asp_send_email.asp
0
 

Author Comment

by:etm_wkl
ID: 37837076
Grateful for the return.
I think that I could not explain the purpose of routine. I do not intend to send or receive mail through VFP. I wish I could choose some incoming and / or sent emails and store them in the database, linking them to customers folders.
For example, each order would have associated with it the confirmation email. Currently I print and keep it in pdf format. It would be nice to store the email itself.

Translate from portuguese:

"Grato pelo retorno.
Acho que não conseguí explicar o objetivo da rotina. Não pretendo enviar ou receber emails pelo VFP. Eu gostaria de poder escolher alguns emails recebidos e/ou enviados e guardá-los no banco de dados, associando-os a pastas de clientes.
Por exemplo, cada pedido teria a ele associado o email de confirmação. Atualmente eu imprimo e guardo no formato pdf. Seria ótimo poder armazenar o email em sí."
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 27

Expert Comment

by:CaptainCyril
ID: 37837090
You can store the EML or MSG as a file in a fixed folder and store its name in the database. You will launch the EML or MSG file by using ShellExecute:

= ExecuteShell("d:\emailfolders\email.msg")

FUNCTION ExecuteShell
LPARAMETERS cFile, cOperation, cDefaultDirectory, cParameters
LOCAL nHwnd, cParameters, cDefaultDirectory, nShowWindow
DECLARE INTEGER ShellExecute IN shell32.dll AS ShellExecute;
      INTEGER nHwnd,;
      STRING @cOperation,;
      STRING @cFile,;
      STRING @cParameters,;
      STRING @cDefaultDirectory,;
      INTEGER nShowWindow
nHwnd = 0
cOperation = IIF(EMPTY(cOperation),'open',cOperation)
cParameters = IIF(EMPTY(cParameters),NULL,cParameters)
cDefaultDirectory = IIF(EMPTY(cDefaultDirectory),'',cDefaultDirectory)
nShowWindow = 1
= ShellExecute(nHwnd, @cOperation, @cFile, @cParameters, @cDefaultDirectory, nShowWindow)
CLEAR DLLS
0
 
LVL 12

Expert Comment

by:jrbbldr
ID: 37839196
I wish I could choose some incoming and / or sent emails and store them in the database

Do you mean the text from the body of the email?

Or do you mean a fully-pathed filename pointing to where the EML or MSG file (or the PDF file copy) is stored separately on your disk?

Precisely what information from the email do you want to store into the database data table?

Good Luck
0
 
LVL 27

Accepted Solution

by:
CaptainCyril earned 2000 total points
ID: 37839212
You can save the email from Outlook or whatever software you use as a file. In the database, you point to that file. Of course it would be ideal to organize the emails in a folder.

In this kind of request, you can't rely on automation. You need to manually do this.
0
 

Author Closing Comment

by:etm_wkl
ID: 37840517
Once solved, the question remains: why did not I think of that before?
The solution was obvious, and I could not see.

Thank you.

Translate from portuguese:

"Uma vez solucionado, fica a pergunta: porque eu não pensei nisso antes?
A solução estava na cara, e eu não conseguia enxergar.

Muito obrigado."
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 37841258
Well, we all tried many solutions and for different projects there are different solutions.

Today it is hard to communicate with Outlook. Before we could do a search of emails and have Outlook open one of them. If you do that, it might become unstable. Office 5/95/97/XP/2003 worked great in automation. The latest versions crash a lot except for Excel.
0
 
LVL 30

Expert Comment

by:Olaf Doschke
ID: 37845895
You can actually also automate the saveas method to save an outlook mail as msg file.

#Define olMSG 3
#Define olFolderInBox 6

oOutlook = CreateObject("outlook.application")
oMapi = oOutlook.GetNamespace('MAPI')
oMapi.Logon('accountname','password')
oFolder = oMapi.GetDefaultFolder(olFolderInBox)
oItem = oFolder.Items(1)
oItem.SaveAs('c:\temp\test1.msg',olMSG)

Open in new window


You can easily go from newest items to older ones by starting with Items.Count, instead of Items(1). a unique ID of each item is in it's oItem.EntryID property, so you can also see, which Items you already have exported, if you store that in your database. You can act on mail subject or body content or whatever.

You can also just store the EntryID and revisit that mail automagically inside Oulook via
oItem = oMapi.GetItemFromID(entryid stored into and read back from mySQL)
oItem.Display()

Open in new window


Of course that only works on the same client, having that outlook account open, but you can of course store a pst on a share and thereby allow access to many users, if the outlook account is some specifically for order mails.

Bye, Olaf.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
I came across an unsolved Outlook issue and here is my solution.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month21 days, 5 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question