At present we are just saving attachments with the database system. Clients can open up and save locally but always have a backup if they delete/mess up the local copy.
Following is part of GetMail method which strips out the actual email address ie xxx@yyy.com - runs a search on all three email fields in this particular system - if match found it gets the customercode & sets as FK in the email document & sets up a link/join table between the Contact and Document.
I
var FullEmail = email_from
if ( !FullEmail )
{
FullEmail = ’ ’
}
var pos1 = 0
var pos2 = FullEmail.length
Many thanks indeed. I’m very much a novice and it really is invaluable to get such good feedback from these forums. I do have a few questions.
I don’t understand the purpose of using newRecord() in the wx_contacts. I can’t see how this helps find existing records that have the email string. Doesn’t this function simply add a new record? If so why is this neccessary?
I also don’t quite understand the purpose of the line “globals.gcurr_link_ctcode = null” as this variable seems to be immediately altered in the next line by assigning it the customercode from wx_contacts. Am I right in guessing that it is there just in case there is no matching email record in wx_contacts?
Also, I would be very interested to see how you save attachments with the database system. I would like to see the alternatives and the more code I look at the more I feel like I’m starting to get a handle on how to use Servoy.
You’re welcome - much of my knowledge - and all the really clever code - has come from this Forum.
I don’t understand the purpose of using newRecord() in the wx_contacts. I can’t see how this helps find existing records that have the email string. Doesn’t this function simply add a new record? If so why is this neccessary?
This enables you to search in multiple fields in the same Search operation
I also don’t quite understand the purpose of the line “globals.gcurr_link_ctcode = null” as this variable seems to be immediately altered in the next line by assigning it the customercode from wx_contacts. Am I right in guessing that it is there just in case there is no matching email record in wx_contacts?
Ensures that gcurr_link_ctcode is null before assigning it to the found record - if any. Belt & braces!
Adding attachments:
var emailID = iddc
var attachments = msg.getAttachments()
I don’t understand the purpose of using newRecord() in the wx_contacts. I can’t see how this helps find existing records that have the email string. Doesn’t this function simply add a new record? If so why is this neccessary?
Graham is just adding new FIND requests with the new record. You can tell because they come after the controller.find but before the controller.search
Graham is just adding new FIND requests with the new record. You can tell because they come after the controller.find but before the controller.search
Thanks for this… big help in making me understand the code fully.
I have another question - I am trying to check the Sent date of the message headers and then only create create records for messages with a unqiue sent date. The code I am using is below. It seems to work fine until the
"var msg = … " even though I have new messages waiting. Where am I going wrong?
var receiveMode = 1;
var headers = plugins.mail.receiveMail(‘myemailaccount’, ‘username’, true ,receiveMode);
if (headers )
{
for ( var k = 0 ; k < headers.length ; k++ ) //look at each header, one at a time.
{
var header = headers[k];
globals.email_message_date = header.getSentDate();
application.output(globals.email_message_date);
application.output(gcheckemail_to_email.getSize())
if (gcheckemail_to_email.getSize() == 0) // check to see if message is already there
{
application.output(header.getSentDate())
var msg = plugins.mail.recieveMail(‘myemailaccount’, ‘username’, true , 0 , header.getSentDate());