Solved

Store emails in MySql tables

Posted on 2012-04-11
9
517 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
Comment Utility
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
 
LVL 41

Expert Comment

by:pcelba
Comment Utility
0
 

Author Comment

by:etm_wkl
Comment Utility
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
 
LVL 27

Expert Comment

by:CaptainCyril
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 12

Expert Comment

by:jrbbldr
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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 29

Expert Comment

by:Olaf Doschke
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now