Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Emailing A List of People using VBA


Hi People

I am trying to use the following code (you'll need to set up References
within the VB screen if you want to try this code):


Public objOutlook As Object
Public objNS As Outlook.Namespace
Public objMsg As Outlook.MailItem
Public objRecipient As Outlook.Recipient
Public strCurrentUser As String
Public strCurrentUserFull As String

Sub MailTest2()
Dim blnDone As Boolean
Dim x As Integer
Dim strSignature As String
Dim strReportDrive As String
Dim strReportDir As String
Set objOutlook = GetObject(, "Outlook.Application")
Set objNS = objOutlook.GetNamespace("MAPI")
Set objMsg = objNS.Application.CreateItem(olMailItem)
With objMsg
.Display
Set objRecipient = .Recipients.Add("Undisclosed Recipients")
objRecipient.Type = olCC
Set objRecipient =
")
objRecipient.Type = olBCC
.Subject = " This is a test"
.Body = "This test should work"
.Attachments.Add "L:\whatever.xls", , intChar + 1
.Body = .Body
.Send
End With

Set objRecipient = Nothing
Set objMsg = Nothing
Set objNS = Nothing
Set objOutlook = Nothing
MsgBox "EMAILS SENT!!!"
End Sub


Questions:

1) Why do the email addresses not go into the correct bits of outlook?
ie setting the BCC doesn't seem to work. however if I type

Set objRecipient =
")
objRecipient.Type = olBCC
Set objRecipient =
")
objRecipient.Type = olBCC

then the second address line goes into the BCC field but the first line
goes into the To field.
The Undisclosed Recipients address part does go into the To field as
required but I've seen this go elsewhere while trying to figure this
out.

2) How do I alter my program to surpress the security warning that keep
popping up?

Thanks

Nick


--
n_s_simpson
------------------------------------------------------------------------
n_s_simpson's Profile: http://www.excelforum.com/member.php...o&userid=31859
View this thread: http://www.excelforum.com/showthread...hreadid=515868

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Emailing A List of People using VBA

Hi n_s_simpson

Look here for Examples
http://www.rondebruin.nl/sendmail.htm

See also the tips link on each page


--
Regards Ron de Bruin
http://www.rondebruin.nl


"n_s_simpson" wrote in message
...

Hi People

I am trying to use the following code (you'll need to set up References
within the VB screen if you want to try this code):


Public objOutlook As Object
Public objNS As Outlook.Namespace
Public objMsg As Outlook.MailItem
Public objRecipient As Outlook.Recipient
Public strCurrentUser As String
Public strCurrentUserFull As String

Sub MailTest2()
Dim blnDone As Boolean
Dim x As Integer
Dim strSignature As String
Dim strReportDrive As String
Dim strReportDir As String
Set objOutlook = GetObject(, "Outlook.Application")
Set objNS = objOutlook.GetNamespace("MAPI")
Set objMsg = objNS.Application.CreateItem(olMailItem)
With objMsg
.Display
Set objRecipient = .Recipients.Add("Undisclosed Recipients")
objRecipient.Type = olCC
Set objRecipient =
")
objRecipient.Type = olBCC
.Subject = " This is a test"
.Body = "This test should work"
.Attachments.Add "L:\whatever.xls", , intChar + 1
.Body = .Body
.Send
End With

Set objRecipient = Nothing
Set objMsg = Nothing
Set objNS = Nothing
Set objOutlook = Nothing
MsgBox "EMAILS SENT!!!"
End Sub


Questions:

1) Why do the email addresses not go into the correct bits of outlook?
ie setting the BCC doesn't seem to work. however if I type

Set objRecipient =
")
objRecipient.Type = olBCC
Set objRecipient =
")
objRecipient.Type = olBCC

then the second address line goes into the BCC field but the first line
goes into the To field.
The Undisclosed Recipients address part does go into the To field as
required but I've seen this go elsewhere while trying to figure this
out.

2) How do I alter my program to surpress the security warning that keep
popping up?

Thanks

Nick


--
n_s_simpson
------------------------------------------------------------------------
n_s_simpson's Profile: http://www.excelforum.com/member.php...o&userid=31859
View this thread: http://www.excelforum.com/showthread...hreadid=515868



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Emailing A List of People using VBA


Ron, you are an absolute genius!!! I’ve been trying to work out how t
do this for a couple of days now and you’ve answered my query in
matter of seconds.

Thanks for your excellent guidance.

Nic

--
n_s_simpso
-----------------------------------------------------------------------
n_s_simpson's Profile: http://www.excelforum.com/member.php...fo&userid=3185
View this thread: http://www.excelforum.com/showthread.php?threadid=51586

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
Help with mailing list!! If 3+ people @ 1 address, send 2, if 5+ s Sean Excel Discussion (Misc queries) 0 March 8th 10 09:08 PM
Formula to create a list of people who qualify Brad Excel Worksheet Functions 2 March 6th 09 11:42 PM
excel - Taking a list of people and adding them to 2 columns ycwkpp898 Excel Discussion (Misc queries) 0 August 5th 08 02:44 PM
print an envelope from my list of people on excell dotcav Excel Worksheet Functions 1 December 14th 06 03:45 PM
How do I randomize a list of 20 people? Ken P Excel Discussion (Misc queries) 2 August 8th 06 10:36 PM


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

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

About Us

"It's about Microsoft Excel"