Copy all email address from continuous form into Outlook email To Line - vba

I have a continuous form in an Access Database that lists each employee assigned to a job and their email address.
I need to insert each email address into the To line in an Outlook email message.

You would need to perform the following operations in VBA in MS Access:
Open a recordset of the query/table constituting the record source of your form - you can do this using the recordsetclone method of the form.
Iterate over the recordset and construct a semi-colon delimited string using the value held by the email address field. Use the constructed string to populate the To field of the email.
Alternatively, use the Add method of the Recipients property of the Mail Item to add each recipient as you iterate over the recordset.

Related

How to display in Outlook, using VBA, a list of emails based on their EntryID (based on a list of EntryIDs stored in MS Access)

I have an Access DB that interacts with Outlook, including capturing the EntryID of selected emails as needed (which are stored in a table in Access)
I have code that allows users to view any email whose EntryID is stored, using Outlook's GetItemFromID method. This works as needed - it opens up a single email based on its EntryID.
However, what I am now looking to do is to filter the main Outlook window, to show emails based on a list of EntryIDs I have saved. So, for clarification, if I have a list of eg 3 emails (with their respective EntryIDs), the main Outlook window would be filtered to show those 3 emails. So basically like a search, but based on EntryIDs.
I can't seem to find anyway to do this? Perhaps there is a way to add a search filter via VBA that will search based on EntryIDs, but I can't find anything on this.
Any ideas much appreciated.
Binary properties like EntryID can't be used in any search or filtering operation in Outlook. You need to use any other properties (custom or user-defined ones) for filtering items in Outlook.
The View.Filter property value is a string, in DAV Searching and Locating (DASL) syntax, that represents the current filter for the view. For more information about using DASL syntax to filter items in a view, see Filtering Items.
Private Sub FilterViewToLastWeek()
Dim objView As View
' Obtain a View object reference to the current view.
Set objView = Application.ActiveExplorer.CurrentView
' Set a DASL filter string, using a DASL macro, to show
' only those items that were received last week.
objView.Filter = "%lastweek(""urn:schemas:httpmail:datereceived"")%"
' Save and apply the view.
objView.Save
objView.Apply
End Sub
Be aware, the EntryID value can be changed when items are moved between stores or folders. Moreover, the value is unique only per store.
If you need to show some items with specific EntryIDs strings you can get these item instances by using the GetItemFromID method and then marking them with a specific user property to be able to apply a filter for it. Or just add another string field to the Db with a custom value which can be added to items in Outlook, so you could easily apply a filter in the UI.

Outlook VBA - Function to retrieve Display Name of an email address

Apologize as I come up without any code, I just simply don't know how to start.
So let say I have an email address. I want to check whether this email address belongs to any contact in any contact folder or in any address book of my Outlook. If yes, I want to retrieve the associate Display Name of the email address. I need the function fast enough to check long list of email addresses.
Hope somebody can help. Thanks.
Try to call Namespace.CreateRecipient / Recipient.Resolve, then read Recipient.Name property. Note that it is not unique.
If you need to resolve multiple entries, create a temporary message, add the values to the MailItem.Recipients collection, call Recipients.ResolveAll.

Filter shared inbox mail by user name which is stored in a user-defined field

We are using a shared inbox. Each mail is assigned to a person. The assignment is done in a user-defined field "Bearbeiter" containing the name of the person.
I want to define a view, in which the person only sees mails he is assigned. I can assign a DASL / sql-filter with the following.
The filter is formatted like a hyperlink but this is the filter condition.
"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/Bearbeiter" LIKE '%max%'
I need 'max' to be replaced by the first name of the user, something like
instr("http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/Bearbeiter";username) <> 0
I could use VBA like in https://www.experts-exchange.com/questions/25904435/DASL-filter-in-Outlook-2003-Username.html, but that would mean I had to call the function every time, which I do not want.

FROM Name MailItem Property

I am trying to record tasks via sending an email in Outlook and I need to have the sender name in the body so the others know the task is assigned to them.
Using MailObj.SenderName does not use the FROM name it would look for the name of the recipient if I was replying.
If you want the current user information, use Application.Session.CurrentUser.

How can retrieve email address from the Infopath people/Group picker

How can retrieve email address from the Infopath people/Group picker?When I add the people/Group picker into the infopath form, I only get 3 fields DisplayName,AccountId,AccountType.Can anyone show me how can I get the email either by configurations or by code.
In SharePoint Designer, when setting up a workflow to respond to an InfoPath people picker field, I simply map the "TO:" field of my "Send Email" action to whatever people picker field I have (even if it's set to pull the Display Name)... and the email will successfully send out regardless. Now, your mileage may vary and perhaps it's due to our Exchange server settings and small company size which allows this to work.
Anyways, try it out. Maybe extracting an email address from the people picker is a superflous step.
I have a simpler solution.
Assume you are using the connection wizard to send an email to a person selected from a people picker.
in the to field -
concat(substring-after(AccountId, "\"), "#domain.com")
assuming your companies mail accounts have an entry for username # domain.
because AccountId = domain\username
so we end up with username#domain.com
Worked for me
Create a button and the following rules for that button.
Create a data Connection to retrieve from GetUserProfileByName.
Create a field to store the email you are retrieving.
Rules for the button
Rule 1 Set a fields value. Set the value of the AccountName of GetUserProfileByName to equal the AccountID from the people picker.
Rule 2 Add an Action to to Query the Data Connection GetUserProfileByName
Rule 3 set a fields value to the email address of the query you just performed
Filter Data
Change value to name
If you simply want to populate a field with the email address from your domain this works perfectly. I have been banging my head on the double eval trick for two days. I got it to work but the form rendering in SharePoint took 2 minutes and 46 seconds.
I know this is too late for the answer but still i am writing this so that someone can get help in future.
When we keep People picker it gives us three values which you specified (AccountId, DisplayName and AccountType).
Now if some one wants to retrieve the email address, there may be so many requirement but i guess most of the person want to send mail to the user which are selected into people picker.
If you want to send mail to selected user then you can just use AccountId field into your workflow item. SharePoint designer automatically detect the email address from the AccountId and sends the mail.
I hope this might save someone's time.