get value from contacts folder

P

Pippo

hy

this is a simple code to send mail ....

Sub InviaEmail()
Dim AppOut As Outlook.Application
Set AppOut = New Outlook.Application
Set NewMail = AppOut.CreateItem(olMailItem)

NewMail.To = (e-mail address removed)
NewMail.CC = (e-mail address removed)
NewMail.BCC = (e-mail address removed)

NewMail.Subject = "blabla"
NewMail.Body = " blabla"
NewMail.Attachments.Add "C:\myfile.txt"
' NewMail.Send
NewMail.Display
End Sub

....but i need to get the "NewMail.To" value directly from my contacts
folder. ( i've a group list named "clientii" with 100/120 members that
sometimes can change and it would be a very boring job to write all the
names to hand or to cancel them and rewrite when they change)


tanks
 
P

Pippo

Dmitry Streblechenko said:
Read the ContactItem.Email1Address property from the contact.
...
hy
i've done it

http://msdn2.microsoft.com/en-us/library/bb220057.aspx
"Returns or sets a String representing the e-mail address of the first
e-mail entry for the contact."

....but i don't know how to use it in my code...

NewMail.To = (e-mail address removed)
NewMail.CC = (e-mail address removed)
NewMail.BCC = (e-mail address removed)

i would be able to write in "NewMail.To=" directly the distribution list
name stored in my contacts folder (NewMail.To="Clienti" or
NewMail.to="query" and not "(e-mail address removed); (e-mail address removed);
(e-mail address removed); ecc ecc"

i don't need to change the DL

....manually from outlook adress book interface i can add and remove members
from the distribution list as i need

tanks
 
D

Dmitry Streblechenko

If the DL comes from one of the contacts folders that are used by the
automatic name resolution (such as the default Contacts folder), you can
just set the MailItem.To property to the name DL. The DL name will be
resolved when you call MailItem.Recipients.ResolveAll or when teh mesage is
sent.
Otherwise you can either set the To property to a ";" separated list of DL
member addresses (loop through the DistListItem.Members collection) or call
MailItem.Recipients.Add for each DL member address.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top