Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Feature Requests
 PowerHome Messageboard : PowerHome Feature Requests
Subject Topic: request for adding mail functions Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
krommetje
Super User
Super User
Avatar

Joined: December 29 2004
Location: Netherlands
Online Status: Offline
Posts: 695
Posted: December 12 2007 at 06:57 | IP Logged Quote krommetje

in another thread this was requested so I would like to make a formal request:

ph_getMailCount() - Returns a count of available messages
ph_getMailHeader(index) - returns sender, date, subject in local variables
ph_getMailBody(index) - returns text of mail body
ph_deleteMail(index) - deletes the mail at index

It would be nice to have these functions... can they be built-in for the coming beta's?

Peter
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
onhiatus
Senior Member
Senior Member
Avatar

Joined: May 12 2004
Location: United States
Online Status: Offline
Posts: 279
Posted: December 12 2007 at 20:59 | IP Logged Quote onhiatus

Dave apparently already has this mostly done - and even released, though undocumented. (see Need help proccesing emails)

Oddly enough yesterday I decided to hack together a work around to start playing with the same functionality you describe. Surprisingly (at lesat to me) it actually looks like it will work well enough, so it might end up being permanent...

See my previous post for the app and some comments: Tool to interface with POP3 mailboxes

Hope it helps...

Edited by onhiatus - December 12 2007 at 21:03
Back to Top View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: December 13 2007 at 00:07 | IP Logged Quote dhoward

I checked out the current email plugin (released but undocumented) and it appears that most of the functionality is there and should be usable. So I went ahead and documented what's available so far:

Code:

The PowerHome Generic Email control plugin allows the user to read and manipulate email using the default MAPI client. Email can be checked on demand or a specific frequency to check can be specified. Email can be both read and deleted. Since the plugin runs in it's own thread, it takes no PowerHome resources and won't hang the PowerHome program if errors occur within the default MAPI client.

Installing:
The PowerHome Generic Email control plugin is contained within the standard PowerHome distribution and consists of two files located in the plugins directory beneath the PowerHome directory. These files are emailpi.pbd and emailpi.reg. To insure proper operation of the plugin, firt open the emailpi.reg file in notepad and scroll to the very end of the file. The next to last line of the file will contain the directory location of the emailpi.pbd file. Being careful not to change anything else, edit this line to match the proper location of the emailpi.pbd file being sure to use double backslashes (\\) as directory separators. When done, close and save the file. Next, register the ActiveX control using the edit emailpi.reg file. Do this by right-clicking the emailpi.reg file from the Windows Explorer and selecting "Merge" from the popup menu.

Launch PowerHome and open the PowerHome Explorer. Navigate to Setup|Controllers and create a new blank plugin line. Give the plugin an appropriate ID and use the following information for the "Launch Data (ActiveX Classname)":

PHPI.Email

For the "Initialization Data" field, enter a single integer value representing the number of seconds you would like for the plugin to scan for new mail. If you wish to initiate the scan manually from within PowerHome, then set this value to 0. In addition to the Init Data specifying the frequency in which to check email, the plugin also uses the MAPILOGIN and MAPIPASSWORD parameters under the [EMail] section within the pwrhome.ini file. These values may be set directly within the pwrhome.ini file or edited within the PowerHome Explorer under the Setup|Email section. You must also have a default MAPI client setup such as Outlook or Outlook Express in order for the plugin to function.

Close the PowerHome Explorer and restart or reinitialize PowerHome in order for the plugin to be loaded. Once PowerHome restarts, go to Help|About|Plugins and verify that the plugin successfully started.

Using the PowerHome File Monitor Plugin:

The PowerHome Generic Email Control plugin supports several commands using the standard ph_picmd function for plugin interfacing. All of the plugin commands use string equivalents in the as_data1 field rather than a numeric command in the ai_cmd field. The ai_cmd value should be set to 0. The list of as_data1 commands are below. In all cases, if the plugin is not currently active, then "101" will be returned from the ph_picmd function. If an invalid command is sent, then "1" will be returned. If the command was successful, then "0" is returned. Specific return values for various errors are detailed in the command section below.

"loadall"
This command will cause the plugin to open a new MAPI mailsession object and load all available email. If a mailsession object is already open, then this command will cause it to be closed and a new mailsession created. The number of messages will be determined and will be set in the current [LOCAL10] system variable. You can also specify the ID of a macro in the as_data2 parameter and the plugin will call this macro with the message count contained in the called macros [LOCAL1] variable. If there is an error while logging in using the MAPI userid/password, a "2" will be returned. If there is an error while retrieving messages, a "3" will be returned.

"loadnew"
This command is similar to the "loadall" command except that only *new* messages will be loaded into the mailsession object. All other aspects are identical.

"getheader"
This command will retrieve header information of a specified email message. The mail message to return header data for should be contained within the al_data1 parameter and should be >= 1 and <= the current mailsession message count (see "loadall" and "loadnew"). If the header information is successfully read, then the current local variables [LOCAL4] thru [LOCAL10] will be populated with the relevant header data. [LOCAL4] will be 1 if the message has not been previously read and will be 0 if already read. [LOCAL5] will be the date received contained within the email header. [LOCAL6] will contain the email subject. [LOCAL7] will contain the address of the email originator. [LOCAL8] will contain the name of the email originator. [LOCAL9] will contain the address of the email recipient. [LOCAL10] will contain the name of the email recipient. If an error occurs while reading the header, "4" will be returned. If al_data1 contains a value outside of the range of email messages, "100" will be returned.

"getbody"
This command will return the text body of a specified email message. The message whose body to receive should be in the al_data1 parameter and should be >= 1 and <= to the total number of messages. The current [LOCAL10] variable will contain the body of the email after function terminates. If an error occurs while reading the body, "5" will be returned. If the specified mail message is out of range, then "100" will be returned.

"deletemsg"
This command will delete the specified email message. The message to delete should be in the al_data1 parameter and should be between 1 and the total number of messages. Out of range values will result in the function returning "100".

"getmsgcnt"
This command will cause the function to return the total number of messages available in the current mailsession object. You must first call either "loadall" or "loadnew" create a mailsession object and retrieve messages into it.

"setfreq"
This command will allow the user to specify a frequency (in seconds) for the control to automatically check for new messages. This frequency can be specified initially when the plugin loads or changed at anytime after loading using the "setfreq" command. The frequency should be in the al_data1 parameter. To turn off automatic checking, set the frequency to 0.

"getfreq"
This command will return the current frequency for automatic message checking.

This plugin will also fire generic plugin triggers if the frequency is set to a value greater than 0 to enable automatic message checking and new messages are available. When new messages are available, a generic plugin trigger for Command 1, Option 1 will be fired. [TEMP3] will contain the current number of messages in the mailsession object (- 1 if there is an error) and [TEMP4] will contain a success/error code. A [TEMP4] value of 0 indicates success. [TEMP4] = 2 indicates an error logging in using the MAPI client. [TEMP4] = 3 indicates an error retrieving messages into the mailsession object.


Check it out and let me know if you have any problems or suggestions.

Tony, I havent had a chance to check out your solution so far but it sounds very interesting. I'll definately check it out because it sounds as if it may be easier to use than the plugin.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum