Email For Selected Contacts

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
One more important question!!!! Given all you have shown me and what I have updated, and now have the code that does things for the selected contacts in different areas. And in a number of folder I don't need to create a distribution list as can change each day. So I created the following code that creates an email for all contacts selected but it only uses the email of the first selected contact....so what can we change quickly so it adds the email address per each selected contact to the email of the selected contacts etc.. This would be great as well!!! Sub EmailTest()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objMsg As MailItem
Dim objItem As Object

Set oContact = GetCurrentItem()
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objSelection = objApp.ActiveExplorer.Selection

For Each objItem In objSelection


Set objMsg = Application.CreateItemFromTemplate("C:\Users\Name\AppData\Roaming\Microsoft\Templates\E-mailForm.oft")
With objMsg
.To = oContact.Email1Address
objMsg.Display
End With

Next
Set objMsg = Nothing
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing

End Sub
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
I just found the way to do this where I select a list of contacts, and it creates an email to each one.....and you can have it displayed or sent as you will see the options below as well.Sub EmailTest1()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objMsg As MailItem
Dim objItem As Object

Set oContact = objItem
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objSelection = objApp.ActiveExplorer.Selection

For Each objItem In objSelection


Set objMsg = Application.CreateItemFromTemplate("C:\Users\Name\AppData\Roaming\Microsoft\Templates\E-mailForm.oft")
With objMsg
.To = objItem.Email1Address

'objMsg.Send
objMsg.Display
End With

Next
Set objMsg = Nothing
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing

End Sub
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Is there a way to change the code above so when I select the contacts, it runs the script that is in the contact that is named Sub btntasks_click and the name of the commandbutton in the contact is btntasks?
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Any update for this tonight?
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
To All: This is the code I worked thru where I used the script code from the contact form to create a macro in a module, that when I select a list of contacts, it creates a task to each one based on the date in field of each contact: Sub Group_Create_Task()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objMsg As MailItem
Dim objItem As Object
Dim remoteObj
Dim StartDate
Dim DueDate

Dim myItem

Set oContact = objItem
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objSelection = objApp.ActiveExplorer.Selection

For Each objItem In objSelection

Set myItem = Application.CreateItemFromTemplate("C:\Users\Name\AppData\Roaming\Microsoft\Templates\Task Follow-Up.oft")

myItem.Display

StartDate = objItem.GetInspector.ModifiedFormPages("General").Controls("OlkDateControl4").value

DueDate = objItem.GetInspector.ModifiedFormPages("General").Controls("OlkDateControl3").value

myItem.StartDate = StartDate

myItem.DueDate = DueDate

myItem.Links.Add objItem
Next
Set objMsg = Nothing
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing

End Sub
 
Status
Not open for further replies.
Top