How to filter the email addresses to be used in the "send email" script step - filemaker

In FM18, I have two tables: "documents" and "recipients".
The "documents" table has (among others) the "owner" attribute, while the "recipients" has the attributes "department" and "emailAddress".
​
I'm working on a script that sends an email message to all the email addresses included in the records having recipients::department = documents::owner.
​
The script is executed when clicking on a button in a layout related to the "documents" table.
​
In the "send email" option form, I have selected "Collect addresses across found set" but now, what should I put in the calculation?
Attached you can find some script (they are in Italian) and the relationship screenshots.

I am somewhat confused by the relationship (?) you describe:
recipients::emailAddress = documents::owner
How many recipients can be related to a single document? It seems like it should be only one.
Assuming it IS a relationship, and that a document CAN have multiple related recipients, you can do any one of the following:
Select the One email using data from the current record option.
Deselect the Collect addresses across found set option. For the
To address, select Specify Calculation… and enter either:
List ( recipients::emailAddress )
or:
Substitute ( List ( recipients::emailAddress ) ; ¶ ; ";" )
Make your script do:
Set Variable [ $message ; "Your message here" ]
Go to Related Record [ From recipients; Show only related records ]
Send Mail [ To: recipients::emailAddress (collect addresses); Message: $message ]
Caveat: much of this is untested (I don't send mails from Filemaker).

Related

Updating Exchange contact group upon contact deletion

I use contact groups with members from a contact list.
Whenever a contact in the contact list is deleted, this previously-added member still exists in the contact group until I hit "update now" in Outlook where the contact group is open for editing. Then a pop-up comes up asking whether I want to delete the no-longer-existing member.
Since I use multiple contact groups I do not want to update each of them individually but with a background job based on the EWS managed API. Thus far I have managed to select each contact group, display members' email addresses, but I do not know how to accomplish this "update now" button-function of outlook! The ordinary update method with AlwaysOverwrite works, but does not do what I want: delete the nonexistent contacts.
(By the way, the contact groups / contact lists reside in public folders.)
EWS doesn't expose that functionality. Essentially, Outlook tries to retrieve the contact by Entry ID, and when it fails, it prompts you to remove it. You could implement something similar (get each email address, try to resolve it back to a contact, etc).
## $service excahnge service referend
## $folder .. ExchangeFolder where group and contacts are
## $group ... instance of contact group
$members = $service.ExpandGroup($group.id)
for($l=0;$l -lt $members.members.count;$l++) {
$curMember = $members.members[$l]
$objViewUser = New-Object Microsoft.Exchange.WebServices.Data.ItemView(1)
$curEmail = $members.members[$l].address
## check if there still exists a contact with this email-address
$searchFilterEA1 = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+ContainsSubstring([Microsoft.Exchange.WebServices.Data.ContactSchema]::EmailAddress1,$curEmail)
$resultContact = $folder.FindItems($searchFilterEA1,$objViewUser).Items.Count
if ($resultContact -eq 0) {
"delete Contact $curEmail"
???????
}
}
}

Outlook FROM field does NOT match Contacts Address Book

Platform: Outlook 2013 as my email client.
Problem: I have contacts stored in Contacts Address Book, not the GAL;
When an email is received from someone, what I see in the FROM field is not equivalent to what is located in MY Contacts Address Book in Outlook.
I see, what I assume, is the way the user set up their account in their respective email service providers.
As an example, I have "Good Friend ", but when I receive an email from this person, it displays, e.g. "John Smith ".
How can I get Outlook "know" to display what my contacts' info in MY contacts address?
You can read the sender email address (MailItem.SenderEmailAddress), open the Contacts folder (Namespace.GetDefaultFolder(olFolerContacts)), search for a matching contact using MAPIFolder.Items.Find with a query like "([Email1Address] = 'user#domain.demo') or ([Emai21Address] = 'user#domain.demo') or ([Email3Address] = 'user#domain.demo')" .
Once you have ContactItem object, read its FileAs property and set the PR_SENDER_NAME and PR_SENT_REPRESENTING_NAME properties on the original message using MailItem.PropertyAccessor.SetProperty. The DASL names of the properties are
"http://schemas.microsoft.com/mapi/proptag/0x0C1A001F"
and
"http://schemas.microsoft.com/mapi/proptag/0x0042001F"

Modifying email templates for Navision 5.0

I've been asked to help do some much needed updates to Microsoft Dynamics NAV 5.0 (yes its old) and they want me to update some of their email templates for sales orders, etc. One of the things they want me to do is update the 'From' field to be a group email box instead of the current user, which I didn't think about be too difficult, but figuring out how NAV creates emails has been less than simple.
This article had some information, but didn't get me all the way there:
http://www.dynamics101.com/2014/02/sending-customized-emails-dynamics-nav/
I've found the Sales Header table which has lots of fields...none of which include "From". I found one field called "Assigned User" which points to the User Setup.
Do you mean the mails that are sent on the event of sales order approval / rejection or that small 'New Mail Message' button in the Customer card? Libraries that are used in these cases are different, and they rely on different automation objects to create e-mail messages.
Anyway, in both cases there is no setup to change the 'From' field - you'll have to customize it a bit.
First of all, you'll need a new field in a setup table to store the e-mail address. Table 'User Setup' is probably the best place, but it depends on the task, of course. Suppose, it is Uset Setup, and you call the new field 'FromAddress'
When you click on the e-mail button in the Customer card, 'Create Mail' wizard is run (Form 5148 'Create Mail'). It calls the function 'NewMessage' in codeunit 397. So, codeunit 397 'Mail', is what you are looking for. To change the 'From' address you need to set the property 'SentOnBehalfOfName' in the OSendMail object.
UserSetup.GET(USERID);
OSendMail.SentOnBehalfOfName(UserSetup.FromAddress);
If the message you want to change is the document approval notification, e-mail message is created in the codeunit 400 'SMTP Mail', but all fields are set up in the codeunit 440 'Approvals Mgt Notification', functions SetTemplate and GetEmailAddress. It is GetEmailAddress that sets the sender address. You need to replace this line of code:
SenderAddress := UserSetup."E-Mail";
with the new one
SenderAddress := UserSetup.FromAddress;
But be careful - this change will affect all templates and all users. If you need to change some templates while leaving other untouched, it is safer to redefine the value of this variable in a function responsible for the particular template. But again, it's all in codeunit 440.

Outlook 2007: Create a message rule that detects autoforwarded messages and handles them

I'm looking for kind of the opposite of creating a rule to auto-forward
emails. I want to create a rule that acts on RECEIVED auto-forwarded emails,
but not any that were manually forwarded or replied to by the same person.
E.g. Jim forwards me all emails with "blah" in the subject, and I want to
move those auto forwards to my "Jim's auto-forwards" folder, but if he
forwards me a message manually that says "blah" but he adds his own comments,
I want it to stay in my inbox.
Outlook seems to know that it is auto forwarded, as it shows up
as such when you view the email. Just above the "From" section but
just below the ribbon, it says something like:
"This message was AutoForwarded."
However I haven't found any option to create a rule filtering these.
Our exchange server (Outlook maybe?) adds the following headers when auto-forwarding:
Auto-Submitted: auto-generated
X-MS-Exchange-Generated-Message-Source: Mailbox Rules Agent
(Visible by opening an email and viewing the message "Properties" to see the headers) These appear to be what Outlook is using to detect that a message was AutoForwarded (or at least coincide)
And Outlook/Exchange 2013 has the filter option "with specified words in the message header"
I have used a rule that looks similar to the following to successfully move only "blah" subject messages autoforwarded from "Jim" to a specific folder:
Apply this rule after the message arrives
from 'jim#example.com'
and with 'blah' or 'blurg' in the subject
and with 'auto-generated' or 'Auto-Submitted' in the message heade
move it to the 'Jims auto-forwards' folder
And this has appeared to prevent any that he's manually forwarded from being processed by the same rule.
Our Exchange Server adds the following header for Auto Forwarded and Auto Replies
X-MS-Exchange-Inbox-Rules-Loop: abc#company.com
where abc#company.com is the email of the person auto forwarding the email.
I use MS Outlook 2010 in which i have setup a rule ->
From: abc#company.com
and with 'X-MS-Exchange-Inbox-Rules-Loop: abc.xyz#company.com'
or 'X-MS-Exchange-Inbox-Rules-Loop: abc.XYZ#company.com' in the message header
move it to the 'xyz' folder
i have checked abc.xyz#company.com as well as abc.XYZ#company.com in message header as in some auto Fwd/Re email header the Lastname of the sender was uppercase.
Note: as mentioned before this rule applies to all Auto Forwarded and Auto Replies (e.g Out of office/ vacation auto replies) from that person. Manual Fwd/RE emails are not filtered
I do not think rules can do this.
Try some VBA. untested
Edit 2013 02 26
Put the code in ThisOutlookSession http://www.slipstick.com/outlook-developer/how-to-use-outlooks-vba-editor/
Here are some references so you can debug if necessary.
NewMailEx: http://msdn.microsoft.com/en-us/library/office/bb147646(v=office.12).aspx
AutoForwarded Property: http://msdn.microsoft.com/en-us/library/office/ff867162.aspx
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim varEntryIDs
Dim objItem
Dim i As Integer
Dim myOlApp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myInbox As Outlook.MAPIFolder
Dim myDestFolder As Outlook.MAPIFolder
varEntryIDs = Split(EntryIDCollection, ",")
For i = 0 To UBound(varEntryIDs)
Set objItem = Application.Session.GetItemFromID(varEntryIDs(i))
'Debug.Print "NewMailEx " & objItem.Subject
If objItem.SenderName = "Jim Smith" Then
If objItem.AutoForwarded then
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
' Assumes destination folder is directly under the Inbox
Set myDestFolder = myInbox.Folders("Jim AutoForwarded")
objItem.Move myDestFolder
End If
End If
Next
Set objItem = Nothing
Set myDestFolder = Nothing
Set myInbox = Nothing
Set myNameSpace = Nothing
End Sub

How would you model an Email app in MongoDB?

How would you model an email app (like gmail) in MongoDB? Would you model a Conversation? Inbox / OutBox? or mail?
Thanks
Gmail use concept of labels (like tags on stackoverflow). That mean that inbox, send mail, starred, etc normal Email object, just marked with specified label. So, there are only Email and Labels.
You can see it using search in gmail like label:inbox or label:Starred.
I'd like to suggest a fairly simple design like this:
Email
{
_id
Title,
Body,
Status {read, unread},
Labels { name, type(system, custom) },
Replies {...},
..
}
Labels
{
_id,
name,
settings {
ShowInLabelsList (show, hide, showIfUnread),
ShowInMessageList (show, hide),
..
}
}
For sure i've missed something, but i guess it's okay to start from above schema and add more features in future if neeed.
Update:
For the 'Conversation View' i guess all replies show go to the nested collection Replies (i've update my schema). Logic is following:
Once you have received a new message you need check if email with same name already exists (for sure need to Remove 'Re', etc..) also need to check that user that has sent email in list of recipients. If above conditions is true then just add new email to nested collection of Replies otherwise add to collection of emails.