?
Solved

Rules in O2K3

Posted on 2006-05-15
9
Medium Priority
?
223 Views
Last Modified: 2010-04-08
Hi,

Can I somehow create a rule that forward a message to a distribution group but puts all receipients in the BCC field?

I tried it in VBA but I just can't set the receipient type to BCC:

Sub FwdFun()

    Dim myItem   As Object
    Dim myolApp As New Outlook.Application
    Dim myOlExp As Outlook.Explorer
    Dim myOlSel As Outlook.Selection
    Dim oForward As MailItem
     
    On Error Resume Next
    Set myOlExp = myolApp.ActiveExplorer
    Set myOlSel = myOlExp.Selection
   
 For Each myItem In myOlSel
     
    If TypeName(myItem) = "MailItem" Then
        Dim RCP As Recipient
        Set RCP = myItem.Recipients.Add("admin@ama.co.il")
        RCP.Type = olBCC
        Set oForward = myItem.Forward
        oForward.Recipients.Add RCP
        oForward.Send
        Set oForward = Nothing
        Set RCP = Nothing
    End If
            myItem.Save
    Next
   
    Set myItem = Nothing
    Set myolApp = Nothing
    Set myOlExp = Nothing
    Set myOlSel = Nothing
   
End Sub
0
Comment
Question by:dneebrkr
  • 5
  • 4
9 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 16688994
Greetings, dneebrkr.

You don't use a Recipient object for BCC addresses.  You use the BCC property.  Something like this:

    olkMsg.BCC = "Someone@somewhere.com; SomeoneElse@somewhereelse.com"

Cheers!
0
 

Author Comment

by:dneebrkr
ID: 16745153
Hi BlueDevilFan,

10x it works. This is the Script: (Do you have any idea how to make Outlook to send the e-mails through a specific account)

Sub FwdFun()
   
    Dim myItem As Object
    Dim myolApp As New Outlook.Application
    Dim myOlExp As Outlook.Explorer
    Dim myOlSel As Outlook.Selection
    Dim oForward As MailItem
    Dim RCP_STR As String

    RCP_STR = InputBox("Destination", "MASS FORWARD", "<>")
    On Error Resume Next
    Set myOlExp = myolApp.ActiveExplorer
    Set myOlSel = myOlExp.Selection
     
    For Each myItem In myOlSel
     
    If TypeName(myItem) = "MailItem" Then
        Set oForward = myItem.Forward
        oForward.BCC = RCP_STR
        oForward.se
        oForward.Send
        Set oForward = Nothing
    End If
        myItem.Body
        myItem.Save
    Next
   
    Set myItem = Nothing
    Set myolApp = Nothing
    Set myOlExp = Nothing
    Set myOlSel = Nothing
   
End Sub
0
 
LVL 76

Expert Comment

by:David Lee
ID: 16828998
Sorry, I lost track of this question.  Here's how to select a particular account.  Change 3 in the code below to the number corresponding to the account you want to use.  Position 1 will always be the default account.  

Sub ChooseSendThroughAccount()
    Dim olkInspector As Outlook.Inspector, _
        ofcBar As Office.CommandBar, _
        ofcButton As Office.CommandBarPopup, _
        ofcCmdButton As Office.CommandBarButton
    Set olkInspector = Application.ActiveInspector
    Set ofcBar = olkInspector.CommandBars("Standard")
    Set ofcButton = ofcBar.Controls(3)
    ofcButton.Controls(3).Execute
    Set ofcButton = Nothing
    Set ofcBar = Nothing
    Set olkInspector = Nothing
End Sub
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

Author Comment

by:dneebrkr
ID: 16830499
BlueDevilFan,

10x,

But it's not working- nothing really changes.

While debugging this is where it gets the first error:
Set ofcBar = olkInspector.CommandBars("Standard")

Run time error '91':

Objext variable or With block variable not set
0
 
LVL 76

Expert Comment

by:David Lee
ID: 16831436
Did you have a message open at the time?
0
 

Author Comment

by:dneebrkr
ID: 16831454
NO
0
 
LVL 76

Expert Comment

by:David Lee
ID: 16831464
A message has to be open for that code to work.  Them menu items it keys on are only available when a message window is open.  There are no other ways I know of to choose the send through account.
0
 

Author Comment

by:dneebrkr
ID: 16840718
I tried using the function 'oForward.Display' right before calling to the 'ChooseSendThroughAccount' Sub.
it opens the selected message but it keeps on sending the message via the default account.

If I want to set the account manually - I click the 'Account' DD menu and then choose an account - how dows your code reflects these actions?
0
 
LVL 76

Expert Comment

by:David Lee
ID: 16840850
> I click the 'Account' DD menu and then choose an account
That's exactly what the code does.  It simulates a click on that menu and then selects the item in the list corresponding to the number passed.  There may be confusion over the numbers.  If you go through these steps manually you see something like this with the list pulled down:

    Account A
    -----------
    1 Account A
    2 Account B

You might think that passing a 2 would get you Account A.  Instead it gets the second instance of Account A.  When deciding what number to pass count the entries from the top down and ignore the numbers that appear onscreen.  In this example the choices are

    1  Account A
    2  Account A
    3  Account B

Make sense?
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question