Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4682 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Where to start.

We are now getting important client information e-mailed to us in the form of attachments.

The attachments have the clients name and a reference number in the file name. ie Smith, John, 1234567.pdf

What I would like is to forward the email message based on the attachment name, inducing the orignal attachment.

Or what would be even better if I could download the attachments, put them in a clients folder then e-mail the staff member alerting them that a clients files have been updated.

Right now I have a server script that runs every 15 minutes to get the mail.

I can see the attachment names, but I am unsure how to work with the files.

Thanks!

-=fred=-

Posted

Hello Fred,

This is not a trivial task to accomplish. There are many ways to approach this and I'll give you the one I think may be the simplest. You'll want to have the incoming messages stored in a table in the database. Then, you'd iterate through the messages and store everything you need in the table (ImportedMessage in this case).

Loop

Exit Loop If [not EmailGetNextMessage]

New Record/Request

Set Field[importedMessage::from ; EmailReadMessageValue( "from" )]

Set Field[importedMessage::to ; EmailReadMessageValue( "to" )]

Set Field[importedMessage::subject ; EmailReadMessageValue( "subject" )]

Set Field[importedMessage::body ; EmailReadMessageValue( "body" )]

Set Field[importedMessage::messageId ; EmailReadMessageValue( "messageId" )]

// OPTIONAL: mark this messages as "viewed"

// (You must pass readonly=false during EmailReadMessages to do this)

Set Variable[$result ; EmailMessageSetFlag("viewed")]

End Loop

You would add functionality to also store the file in a container field in the corresponding record. This could be accomplished by first passing in the optional flag "attachments=true" to the EmailReadMessages function. That will cause the files to be downloaded to a temp directory. You can then get the path of the attachment by calling EmailReadMessageValue( key ) with "key" being "attachments." Be careful here. This will return multiple lines of path names if there is more than one attachment. You'd probably also want to handle the cases where the emails either had no attachment, or not client attachments. This could be done with some clever scripting.

Once you have the path (still in the message iteration process) you can store the file in an "attachment" field in the ImportedMessage table mentioned above. You'd use the EmailReadAttachment( path ) with the result from EmailReadMessageValue above. At this point you'd have the associated attachment file in the same record as the message. If you are storing all messages in the table you may want to set a flag or something to differentiate between these specific kinds of emails.

From here you can do whatever else you need (send message with attachment, save files in client folder, etc.) in either the same server scheduled script (though I advise against it) or a different one for sending messages. In this script you could change another flag in the record based on a successful send of the email to avoid resending. You could also save the files to a unique client directory too.

I realize this may seem a bit complicated and depending on your level of experience it may be challenging. Keep in mind, we offer custom script development and are happy to offer you a quote. If you're interested in a quote please email me directly.

This topic is 4682 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.