Email Attachment loop.

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Madimant
Posts: 35
Joined: Tue Aug 08, 2017 11:39 pm

Email Attachment loop.

Post by Madimant »

I am trying to simplify my outgoing email routine.

I need to attach a combination of 20 different documents to an outgoing email. Mostly 5 of the documents but hardly ever more than 7.
Currently, I have BO outgoingmail with 20 document attributes and a rule for every attribute (attachment). If I don't want to send that specific document I leave that attachment empty.
This creates every single outgoing email BO with lots of unused attached and every time I add another possible document I need to add an addition attachment attribute. I find this very long-winded and inefficient.

I can select my 5 to 7 documents for the mail to send but how do I get them into say attachment 1 to 7?

I cannot seem to find anything like this on the forums.

Any help will be appreciated.
Tj
Tj
Using Version 8.6 Build 2917 - mySQL
Jaymer
Posts: 2450
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Email Attachment loop.

Post by Jaymer »

well, you've answered it yourself.
You need to make 1 attachment.
Copy them into a temp physical directory.
Execute a zip.exe to zip that folder into 1 file. Attach only that file & send.

As you've experienced, the existing method is untenable. Best to just invest the time into going the Zip route and the whole process improves.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Madimant
Posts: 35
Joined: Tue Aug 08, 2017 11:39 pm

Re: Email Attachment loop.

Post by Madimant »

Thanks Jaymer

Not really what I wanted to do as I needed to have attachments as readable separate pdf's
but managed to figure it out ...

FIND Documents IN BATCHES OF 1 (as the loop)
Then use - IF Attachment1 IS UNDEFINED assign it ELSE IF Attachment2 IS UNDEFINED THEN assign it.....up to 7
Tj
Using Version 8.6 Build 2917 - mySQL
customaware
Posts: 2400
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: Email Attachment loop.

Post by customaware »

I would do it with a Non Persistant BO.

Will do up a small demo for you tomorrow.
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
PointsWell
Posts: 1458
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Email Attachment loop.

Post by PointsWell »

eagles9999 wrote:I would do it with a Non Persistant BO.

Will do up a small demo for you tomorrow.
Non persisted BOs are the neglected superheros of AIM. Will fix all kinds of context issues. They are alleged to make you better looking and able to return the colour to your hair. Allegedly.
customaware
Posts: 2400
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: Email Attachment loop.

Post by customaware »

And they can leap tall buildings in a single bound.

Once I discovered them....I use them in so many places....mostly
employing the While Syntax
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
Madimant
Posts: 35
Joined: Tue Aug 08, 2017 11:39 pm

Re: Email Attachment loop.

Post by Madimant »

Thanks Mark

Looking forward to getting this one out of my hair!
Tj
Using Version 8.6 Build 2917 - mySQL
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: Email Attachment loop.

Post by BobK »

Madimant wrote:IF Attachment1 IS UNDEFINED assign it ELSE IF Attachment2 IS UNDEFINED THEN assign it.....up to 7
I have done something similar to this in several places. But now I do, IMO, something better using EXEC_STRING.

You will need a new BO with a Plain Text Field and a Number field that has an initial value of 1. This can even be a Non Persistent BO. :)

Before you find your Documents, CREATE the new BO.
Then set the Plain Text field to:
NewBO.PlainText=`EMail.Attachment`+AS_STRING(NewBO.TheNumber, '#')+`=Documents.Attachment`
NOTE: Use your real BO and attribute names and pay attention to the ' and `

Replace your IF ... ELSE ... with
EXEC_STRING NewBO.PlainText

And add:
INCREASE NewBO.TheNumber BY 1
NewBO.PlainText=`EMail.Attachment`+AS_STRING(NewBO.TheNumber, '#')+`=Documents.Attachment`


The above assumes that all Attachments are UNDEFINED to start with.
If you ever need to increase the number of attachments to your emails, this process will not need to be changed.
Bob
Jaymer
Posts: 2450
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Email Attachment loop.

Post by Jaymer »

BobK
Does this approach still need the 20 attachment fields?
And if he finds he needs a 21st, does he, as he said in his post, still have to alter the table to add the 21st?
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: Email Attachment loop.

Post by BobK »

Jaymer wrote:BobK
Does this approach still need the 20 attachment fields?
And if he finds he needs a 21st, does he, as he said in his post, still have to alter the table to add the 21st?
Yes, he still needs the 20 attachment fields on the outgoing email.
If he needs additional attachment fields, he would have to add them to the outgoing email, but my process would not need to be changed. Where as in his current logic he would have to add another ELSE clause to his large If statement.

In summary, After his FIND statement finds X Documents (X being any number less then or equal to the number of Attachment fields on the Outgoing Email) my version of the process will attach each document to a separate attachment field beginning with Attachment1 then Attachment2 and so on until all documents have been processed.
Bob
Jaymer
Posts: 2450
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Email Attachment loop.

Post by Jaymer »

Bob, ok, I'm with you.
Anything to make it less Tedious - got it.
Was hoping you'd found some hidden way to not have to physically have 20 fields.

To be clear, you still have 20 Fields ALSO in the Notification, and 20 Rules like below (ie. attach1 thru attach20):
Screen Shot 2020-06-17 at 1.18.47 PM.png
Screen Shot 2020-06-17 at 1.18.47 PM.png (75.67 KiB) Viewed 10274 times
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: Email Attachment loop.

Post by BobK »

Actually, I don't think I have ever sent an AwareIM email with an attachment.

You still need the 20 Attachment field on the Notification, but can't you attach the documents directly to the Notification in a Process?
Bob
Madimant
Posts: 35
Joined: Tue Aug 08, 2017 11:39 pm

Re: Email Attachment loop.

Post by Madimant »

Thank BobK

This is a great way to dynamically put together an BO.attribute...
Something I could never work out before and wanted to do in another section of my program.

There are so many ways to do things in Aware and taping into the wealth of information in the forum is great!

Tj
Tj
Using Version 8.6 Build 2917 - mySQL
Post Reply