Selected Contacts For E-Mails

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Email Account
Exchange Server
Below is the code that when I select any number contacts in a folder, I can send one email to all of them together using a email template.

But if I select a contact from different folders, it does not do it...so is there a way to change this so if I select more than one contact from different contact folders, it sends the email to both of them together. Thank much as usual!!

Public Sub SendToSelectedContacts()
Dim Selection As Selection
Dim strDynamicDL As String
Dim obj As Object
Set Selection = ActiveExplorer.Selection

For Each obj In Selection
If obj.Class = olContact Then
strDynamicDL = strDynamicDL & ";" & obj.Email1Address
Else
strDynamicDL = strDynamicDL & ";" & obj.DLName
End If
Next

Dim objMsg As mailItem
'Set objMsg = Application.CreateItem(olMailItem)
Set objMsg = Application.CreateItemFromTemplate("C:\Users\UserName\AppData\Roaming\Microsoft\Templates\E-mail Form.oft")
objMsg.To = strDynamicDL

objMsg.Display


Set objMsg = Nothing
Set obj = Nothing
End Sub
 
No...just got to the folder or subf folder and select the contacts
 
I'm not sure how you are selecting contacts from different folders - the code is looking at the selection and the only way to select contacts in different folder is if you are using search.
 
Got it.....how can I search more than one contact? So pretend I am searching Diane Pormesky and Lou Stoler? How do I do that? And if that shows up the contacts, I can just select both? Correct? As When I search both contacts, they don't show up.

And is there a macro to search so if I need to send the email to the same group each time, I can run that macro, it shows the contacts...and selected each one, and creates an email to them together as a default email form or a email template i use?

Thanks much.
 
If you use the right criteria, you can search for different people, but it can get messy if you have more than a few names to search. I'm also not sure what limitations you'll have in 2007 - you might need to do it differently.

The Instant Search criteria would be something like this: fullname:(diane OR lou). I've had issues searching for two when using the full name, but partial names works.

You can use a macro to do a search, but I'd recommend using Color Categories to mark people you might want to sent mail to as a group and use the category as the criteria when searching. Using categories is recommended over creating contact groups (distribution lists) because thye are more easily edited and updated.
 
Right before I got this, I found to do it with the word OR between the two names...and as to each name before and after it put in a "....so it is exactly those words...and when they all show up, I select them and everything works as if they are in the same folder......So I don't want use Categories.....can you give me the macro that does a search re the words I put in the macro..for example: "Diane" OR "Lou" and it shows each of those, and selects each of those automatically and creates the email to both of them? That would be very helpful. Thanks much.
 
It should work across all contact folders, but there is a search option that limits it to the current folder. I think it's the default setting. Check in Search Options for that setting. I don't know of a way to force it to search all folders in a simple search - you can force it if you are using VBA. I have a code sample here -

http://www.slipstick.com/how-to-outlook/how-to-create-a-unified-inbox/ - i think it will work with Outlook 2007.
 
So is this it and I replace txtSearch = "category:(Business)" with "Diane" OR "Lou" ?

Sub SearchByName()
Dim myOlApp As New Outlook.Application
txtSearch = "category:(Business)"
myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders
Set myOlApp = Nothing
End Sub
 
To search for several contacts, this works but it does not only search the name itself as when I type in the search it is "Diane" OR "Lou" and if any of those words are part of another contact, not just the name but those letters...it shows up on with respect to those named specifically...but in the code it does not do that, so what do we change so it only searches the names and not any other words that have those names in a word: So here is the code to fix:

Sub SearchByName()
Dim myOlApp As New outlook.Application
txtSearch = "Lou OR Diane"
myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders
Set myOlApp = Nothing
End Sub
 
Once again...I need the search to show "Lou" OR "Diane" but can't figure out how the search includes before and after each name a " as that in the search only searches the exact word...not in any other words those words are in
 
To All if this Helps......this does it:

Sub SearchByName()
Dim myOlApp As New outlook.Application
txtSearch = """Lou"" OR ""Diane"""
myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders
Set myOlApp = Nothing
End Sub
 
Must figure out how to turn off automatic smilies for one post...:)
you need to use the full search query - fullname: (diane or lou) not just diane or lou.
 
I don't understand the difference in searching for full name. What to do please?
 
txtSearch = "fullname: (diane poremsky or lou)"

with the proper number of quotes, if you want to wrap the search terms in quotes.
 
I did the normal search stuff you gave me and it works great using the email template i want...that i could change....

So instead of searching the contacts, if I have the email addressed...what macro do change above and how so i just now search to send the email to the selected...it creates an email to the email addresses together I put in the macro?
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Witzker Add a text line at the end of the note field in all selected Contacts Outlook VBA and Custom Forms 7
G Autocomplete adds suspicious "@unknown.email" to selected contacts Using Outlook 1
M code to move selected Outlook contacts to another folder Using Outlook 3
P Is it possible to write a macro to email to all addresses of selected contacts? Using Outlook 1
L Email For Selected Contacts Using Outlook 5
P Export selected contacts to a .csv Using Outlook 2
H Move Selected emails to Local Drive Outlook VBA and Custom Forms 0
D Delete selected text in outgoing email body Outlook VBA and Custom Forms 0
D Outlook VBA forward the selected email to the original sender’s email ID (including the email used in TO, CC Field) from the email chain Outlook VBA and Custom Forms 2
E Outlook 365 Save Selected Email Message as .msg File - oMail.Delete not working when SEARCH Outlook VBA and Custom Forms 0
E Save Selected Email Message as .msg File - digitally sign email doesn't works Outlook VBA and Custom Forms 1
O Replace hard returns with soft returns on selected text and button to QAT Using Outlook 5
N Save Selected Email Message as .msg File Outlook VBA and Custom Forms 12
G VBA to save selected Outlook msg with new name in selected network Windows folder Outlook VBA and Custom Forms 1
N Save selected messages VBA does not save replies and/or messages that contain : in subject Outlook VBA and Custom Forms 1
Bering Forward selected email without the original email appended Outlook VBA and Custom Forms 0
A Apply Selected Emails to outlook rules and Run Rules Using Outlook 5
B Change row background color of selected item Using Outlook 1
T Change the selected Message in the Outlook window Outlook VBA and Custom Forms 2
H Custom Signature Not Displayed When Account Selected Outlook VBA and Custom Forms 10
J Checkboxes when selected will appear in a textbox in Outlook 2016 Outlook VBA and Custom Forms 1
K How to reference the selected folder Outlook VBA and Custom Forms 1
R VBA Code to permanently delete selected email Outlook VBA and Custom Forms 10
P Outlook 2013 opens with FILE tab selected. Using Outlook 3
C Change Subject Line in Selected Emails Outlook VBA and Custom Forms 1
D Saving Selected Emails as PDF and saving Attachments Outlook VBA and Custom Forms 6
D Print Attachments only in selected emails using a macro Outlook VBA and Custom Forms 3
O On click,I want to change subject line of selected mail and then reply to particular email and move Using Outlook 3
B Macro to manually move selected emails to network folder Outlook VBA and Custom Forms 1
A Helping OL remember which calendars were selected Using Outlook 6
Diane Poremsky Save Selected Email Message as .msg File Using Outlook 11
D Delete selected text from incoming emails Outlook VBA and Custom Forms 25
mikolajek Random message selected after hard delete Using Outlook 4
Diane Poremsky Working with All Items in a Folder or Selected Items Using Outlook 0
Diane Poremsky Outlook VBA: Work with Open Item or Selected Item Using Outlook 0
A VBA to create meeting from template from a time slot selected in someone's calendar Outlook VBA and Custom Forms 5
Diane Poremsky Create Task or Appointment and Insert Selected Text Using Outlook 0
Yusufbodrum Highlighting selected mails in any folder Using Outlook 2
P Subject change on selected emails Outlook VBA and Custom Forms 14
C Autofill subject line in appointment from options selected in combobox Using Outlook 6
M Save selected email message as .msg file (with user to choose folder location) Outlook VBA and Custom Forms 14
S Macro to print & move selected emails? Using Outlook 3
K Help! I selected every contact and mistakenly made them all the same category Using Outlook 1
C Outlook 2010 Address Book, won't stay selected Using Outlook 5
L Outlook 2007 E-Mail From Selected Task Using Outlook 18
D Trigger macro to run when selected email is opened Using Outlook 3
D Launch Outlook showing only selected messages. Using Outlook 1
J Capturing forward event when multiple items are selected Using Outlook 0
S Printing Selected Date Range in Monthly Style Using Outlook 1
S Outlook 2003: Help with setting up a macro to reply to selected emails Using Outlook 2

Similar threads

Back
Top