Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default VB to send email via outlook to a distrobution list

I am trying to send an email from excel to a distrobution list in
outlook. Any nifty code out there?

I found this on a group but can't get it to work.

Const olFolderContacts = 10
sDistName = "Friends" 'set the distribution list name here

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")

Set colContacts = objNamespace.GetDefaultFolder
(olFolderContacts).Items
intCount = colContacts.Count

For i = 1 To intCount
If TypeName(colContacts.Item(i)) = "DistListItem" Then
Set objDistList = colContacts.Item(i)
sEmails = "";
If objDistList.DLName = sDistName Then
For j = 1 To objDistList.MemberCount
sEmails = sEmails & ";" & objDistList.GetMember
(j).Address
Next

'send the mail using the emails u got! ;-) enjoy
End If
End If
Next

Any help will be appreciated.

Thanks,
paul
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default VB to send email via outlook to a distrobution list

Hi Paul

Use

..Recipients.Add "GroupName"

See more tips here
http://www.rondebruin.nl/mail/tips2.htm

And code examples here
http://www.rondebruin.nl/sendmail.htm


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Paul Lambson" wrote in message ...
I am trying to send an email from excel to a distrobution list in
outlook. Any nifty code out there?

I found this on a group but can't get it to work.

Const olFolderContacts = 10
sDistName = "Friends" 'set the distribution list name here

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")

Set colContacts = objNamespace.GetDefaultFolder
(olFolderContacts).Items
intCount = colContacts.Count

For i = 1 To intCount
If TypeName(colContacts.Item(i)) = "DistListItem" Then
Set objDistList = colContacts.Item(i)
sEmails = "";
If objDistList.DLName = sDistName Then
For j = 1 To objDistList.MemberCount
sEmails = sEmails & ";" & objDistList.GetMember
(j).Address
Next

'send the mail using the emails u got! ;-) enjoy
End If
End If
Next

Any help will be appreciated.

Thanks,
paul

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default VB to send email via outlook to a distrobution list

Ron, thanks! the websites you listed are a great resource.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default VB to send email via outlook to a distrobution list

I'm unable to bypass the security feature. I am using this line of
code
.Display
Application.Wait (Now + TimeValue("0:00:02"))
Application.SendKeys ("%s"), False
rather than a .send but the sendkeys are not working.

and advise?
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default VB to send email via outlook to a distrobution list

Yep

Text from the page

Note: SendKeys is not always reliable and this will not work on every computer
The S is from Send, if you not use a English version you must change this letter.
This tip is not working for the SendMail examples in the first section on my mail page.

Maybe it is working if you close the VBA editor

See this page for other options
http://www.rondebruin.nl/mail/prevent.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Paul Lambson" wrote in message ...
I'm unable to bypass the security feature. I am using this line of
code
.Display
Application.Wait (Now + TimeValue("0:00:02"))
Application.SendKeys ("%s"), False
rather than a .send but the sendkeys are not working.

and advise?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Send a Sheet as body of Outlook Email David Ackerman on cape cod Excel Discussion (Misc queries) 0 March 19th 10 03:11 PM
Send email with Outlook MagicMan Excel Programming 2 October 21st 08 05:53 PM
send email macro with Outlook running DaveH Excel Programming 0 May 22nd 08 06:14 PM
Send Range to Outlook and Email it markb Excel Programming 0 October 15th 07 06:05 PM
***** PLEASE HELP **** Send an email from Excel to outlook with an automatic macro SAM SEBAIHI Excel Discussion (Misc queries) 0 November 11th 06 08:17 AM


All times are GMT +1. The time now is 02:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"