Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

new mail message indication or event fireing 1

Status
Not open for further replies.

PeriyurParthi

IS-IT--Management
Jul 18, 2001
258
0
0
IN
hi all, i need a great help from you all.
i have a project based upon email reciveing. when ever i receive an email, i need to update into the table.
i have microsfot outlook for receving messages. based upon the subject field content it will search for the record and been updated in a particular record. this has to be done automatically. lot of replies will be helpful.cheers
parthi
 
Hi Parthi

Use the MS Communication controls on a VFP Form - Use the properties/methods of the control to check mails directly from Outlook folders and you can also use VFP Timer control to call these checks automatically.

Hope this will help. For more details you can again ask giving the specific problem you are having.

Vikas
 
can i have the sample code for as if am new to this concept. thanks a lot
parthi
 
PeriyurParthi

Lets assume that the messages you are receiving are currently marked as unread and the subject line contains the word "Update", the following will allow you to do that.

Code:
Local oOutlookObject,olNameSpace
#Define olFolderInBox 6
oOutlookObject = Createobject("Outlook.Application")
olNameSpace = oOutlookObject.GetNameSpace("MAPI")
oItems= olNameSpace.GetDefaultFolder(olFolderInBox).Items
For Each loItem In oItems
	If loItem.unRead And "Update" $ loItem.subject
 **Do some updating of your tables here
		loItem.unRead = .F.
	Endif
Next


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
thanks very much mike. sorry for my late reply. the code works fine. but i need to update in the database when ever a new mails arrives. ie whenever a new mail arrives the code should work. some thing like it has to listen for the new mail. let me explain my project.
i have a 3 different locations, the datas should be up to date updated in all 3 different location. as am supposed not to go for high investment expenditure like VPN, leased line, or deicated line etc etc.. netowrking, am doing it in a simple way. so when ever they(in 3 locations) add or edit records, my program will auotmatically send a formated message to all users. next step is when ever remaining locations receives a new message, it will find the proper record useing formated mail and update. so that all my locations will be up to date and updated. hope you have understood. lot of replies will be more helpful in this issues. thanks a lot.
periyurparthi
 
PeriyurParthi

but i need to update in the database when ever a new mails arrives.

You can do your updates at this location

For Each loItem In oItems
If loItem.unRead And "Update" $ loItem.subject
**Do some updating of your tables here
loItem.unRead = .F.
Endif
Next


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
thanks mike,
i hope u didnt understand my explanation at the above post.let me want to know the clear details.

1) whenever i receive a new mail the above code has to fire automatically. how do i know that a new mail has received?? not by checking the unread mails. you know there is a option in microsoft outlook. when ever a new mails arrives microsoft outlook will play sound and give indication that "New Mail has Ariived. Would Like to Read Now? " . I need it like that. your advice and postings will be much helpful in this issues.
thanks a lot
periyur
 
periyur

you know there is a option in microsoft outlook

I'm sorry, I cannot help you there, I am aware that there is an event in Outlook that triggers when new mail has arrived, I read an article on how to access it about 3 years ago in FoxPro Advisor magazine (I believe it's but I cannot find that issue. Checking unread e-mails is the only way I can think of right now. Perhaps someone else can help on this.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
A simplier solution, may be, setting a rule.

Can you set an outlook rule that will run a process? I don't know the answer to that - just brainstorming. If so, you can set the rule to run some code similar to what Mike posted.



Jim Osieczonek
Delta Business Group, LLC
 
periyur (And Jim)

Here is the solution. Use the following code, compile as a COM server, run it as a service and you'll get a messagebox that will appear when new mail has arrived. You could instead of a messagebox, detect the new message a copy it into another directory, or whatever your requirements are. (Noter this requires VFPCOM.COMUTIL to be installed, you can find it in the dowmload section of Microsoft.)
Code:
#DEFINE VFPCOM_CLSID  "VFPCOM.COMUTIL"
#DEFINE OUTLOOK_CLSID  "OUTLOOK.APPLICATION"
public goVFPCOM, goOutlook, goLink
goVFPCOM = create(VFPCOM_CLSID)
goOutlook = create(OUTLOOK_CLSID)
goLink = create('OutlookApplicationEvents')
goVFPCOM.BindEvents(goOutlook, goLink)
DEFINE CLASS OutlookApplicationEvents AS custom
  PROCEDURE ItemSend(Item,Cancel)
  ENDPROC
  PROCEDURE NewMail
  MessageBox('New Mail Has Arrived')
  ENDPROC
  PROCEDURE OptionsPagesAdd(Pages)
  ENDPROC
  PROCEDURE Quit
  ENDPROC
  PROCEDURE Reminder(Item)
  ENDPROC
  PROCEDURE Startup
  ENDPROC
ENDDEFINE




Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
dear mike,
it was really helpful for me. thanks a lot for your posting. mean time am useing visual studio 6.0. when i try to instal vfp com utility, it just gives the error as DLL Failed to Register. i might the utility could be for VFP 8.0. is there any alternative source to over come this problem.
thanks
parthiban
 
The code I suggested above also works in VFp6.0. So your problem is most likely with VFPCOM. I would suggest you try to reinstall it. Installing VFPCOM should be unrealted to the version of VFP you have.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
exactly mike,
i tried to remove and reinstall the utility. but in vain. am useing XP os and MS Visual studio 6.0. i dont know what might be wrong with. when i try to install the utility its giving error as

error 1904.module c:\programfiles\vfpcom\vfpcom.dll failed to register. HRESULT. Contact your support personnel.

any ideas..
thanks a lot
periyur
 
PeriyurParthi

It sounds like a permission situation. Are you logged on with a user that would have the permission to install components that write to the registry? If not not try logging on as an adminstrator.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top