A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Can I restrict email sent in Outlook without using Exchange?



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 17th 08, 01:54 AM posted to microsoft.public.outlook.program_vba
answrtek[_2_]
external usenet poster
 
Posts: 1
Default Can I restrict email sent in Outlook without using Exchange?

We are a very small company, using Outlook v.2000 through a web hosting
solution for our email. Email is setup to send and receive perfectly. We do
not have or even know how to use Exchange, and cannot afford it at any rate.
We have 10 or so computers, each with a stand alone version of Outlook v.2000
installed and users have a single email address to send / receive email from.
All computers are Win xp, fully patched.

For security and productivity purposes we want to limit the ability of a user
to send an email from Outlook (with or without attachments) to only those
email addresses that are listed in the contacts folder or ,alternatively we
would like to be able to specify a single domain name that you can send to
and restrict all others. Either approach would work for our purposes, however
the single domain approach would be best. (like @thisdomain.com) for some
users and the contacts better for others (based on position)

I've been able to accomplish a lot of things with Visual basic like this in
the past with almost every other Office application, (Access, Word, Excel,
PowerPoint) yet cannot seem to wrap my mind around how to accomplish this in
Outlook.

Every idea I've tried fails or just doesn't run, even if it compiles ok.
Rules don't seem to have this option and I haven't seen any 3rd party
affordable or even free software that can accomplish this. The only solutions
I seen are for Exchange administrators, and Like I said we do not have or use
Exchange.

To me, using VB Code it seems like I should be able to:

intercept the send command (i.e.- on the send button clicked etc)

compare the TO (and CC and BCC) recipient value in the email to the various
email addresses in the contacts folder (email1Address, email2Address, etc),
looping through all the contacts

and

allow it and send it if it matches (maybe even give a msgbox "Email matched,
send OK)

or

Disallow it if it doesn't (msg box "Sorry this message....etc) vbOkOnly etc
and not let it complete the send command

I'm at a loss. Can anybody help me with the VB code necessary to handle this
kind of event in Outlook? I've been googling and reading online posts for
three days and haven't seen anything that addresses this kind of need.

Seems simple, yet it is driving me a little goofy.

Thankx in advance,

--
Sanity calms, but madness is more interesting. -John Russel

  #2  
Old November 17th 08, 02:20 PM posted to microsoft.public.outlook.program_vba
Alan Moseley
external usenet poster
 
Posts: 61
Default Can I restrict email sent in Outlook without using Exchange?

Try pasting this code into your ThisOutlookSession vba window. I haven't
answered your question fully as I could spend all day on this, but it should
be enough for you to work out the remainder. For example you haven't
considered if the recipient is in a distribution list, and my code assumes
that there is only one recipient.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim mi As MailItem
Dim cf As MAPIFolder
Dim ob As Object
Dim ct As ContactItem

If TypeName(Item) = "MailItem" Then
Set mi = Item
'Check if domain matches our chosen one
If Right(mi.To, Len(mi.To) - InStr(mi.To, "@")) = "amitc.co.uk" Then
Exit Sub
End If
'Now check if the recipient is in the contacts folder
Set cf =
Outlook.GetNamespace("MAPI").GetDefaultFolder(olFo lderContacts)
For Each ob In cf.Items
Select Case TypeName(ob)
Case "ContactItem"
Set ct = ob
If ((ct.Email1Address = mi.To) Or (ct.Email2Address =
mi.To) Or (ct.Email3Address = mi.To)) Then
Exit Sub
End If
Set ct = Nothing
Case "DistributionList"
'You might want to consider this possibility!
End Select
Next
End If
'If we get this far then we need to cancel the email
MsgBox "Email not sent"
Cancel = True
End Sub
--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"answrtek" wrote:

We are a very small company, using Outlook v.2000 through a web hosting
solution for our email. Email is setup to send and receive perfectly. We do
not have or even know how to use Exchange, and cannot afford it at any rate.
We have 10 or so computers, each with a stand alone version of Outlook v.2000
installed and users have a single email address to send / receive email from.
All computers are Win xp, fully patched.

For security and productivity purposes we want to limit the ability of a user
to send an email from Outlook (with or without attachments) to only those
email addresses that are listed in the contacts folder or ,alternatively we
would like to be able to specify a single domain name that you can send to
and restrict all others. Either approach would work for our purposes, however
the single domain approach would be best. (like @thisdomain.com) for some
users and the contacts better for others (based on position)

I've been able to accomplish a lot of things with Visual basic like this in
the past with almost every other Office application, (Access, Word, Excel,
PowerPoint) yet cannot seem to wrap my mind around how to accomplish this in
Outlook.

Every idea I've tried fails or just doesn't run, even if it compiles ok.
Rules don't seem to have this option and I haven't seen any 3rd party
affordable or even free software that can accomplish this. The only solutions
I seen are for Exchange administrators, and Like I said we do not have or use
Exchange.

To me, using VB Code it seems like I should be able to:

intercept the send command (i.e.- on the send button clicked etc)

compare the TO (and CC and BCC) recipient value in the email to the various
email addresses in the contacts folder (email1Address, email2Address, etc),
looping through all the contacts

and

allow it and send it if it matches (maybe even give a msgbox "Email matched,
send OK)

or

Disallow it if it doesn't (msg box "Sorry this message....etc) vbOkOnly etc
and not let it complete the send command

I'm at a loss. Can anybody help me with the VB code necessary to handle this
kind of event in Outlook? I've been googling and reading online posts for
three days and haven't seen anything that addresses this kind of need.

Seems simple, yet it is driving me a little goofy.

Thankx in advance,

--
Sanity calms, but madness is more interesting. -John Russel


  #3  
Old November 18th 08, 02:31 PM posted to microsoft.public.outlook.program_vba
answrtek
external usenet poster
 
Posts: 5
Default Can I restrict email sent in Outlook without using Exchange?

I appreciate your help Alan.

At least now I have a beginning that interacts with the send routine. I'll
fiddle with it for a bit and see if I can get it to do what I want it to. At
this point I can see it run line by line, and it is comparing input name in
the TO field versus the data stored in contacts, however it doesn't see a
match with that data even if it appears to be the same.

What can you do , in order to have the code compare an input email address
to a resolved name?

For example in this piece of code:

"ct.Email1Address = mi.To", the input address (mi.To) might be like
" .

Outlook resolves this like "Mike Johnson" on an email.

The Contact folder says Mike Johnson in the full name field.
Which looks like "Mike Johnson*, in the code as it runs, yet the underlying
email1 address = )

I'm missing something.

"Alan Moseley" wrote:

Try pasting this code into your ThisOutlookSession vba window. I haven't
answered your question fully as I could spend all day on this, but it should
be enough for you to work out the remainder. For example you haven't
considered if the recipient is in a distribution list, and my code assumes
that there is only one recipient.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim mi As MailItem
Dim cf As MAPIFolder
Dim ob As Object
Dim ct As ContactItem

If TypeName(Item) = "MailItem" Then
Set mi = Item
'Check if domain matches our chosen one
If Right(mi.To, Len(mi.To) - InStr(mi.To, "@")) = "amitc.co.uk" Then
Exit Sub
End If
'Now check if the recipient is in the contacts folder
Set cf =
Outlook.GetNamespace("MAPI").GetDefaultFolder(olFo lderContacts)
For Each ob In cf.Items
Select Case TypeName(ob)
Case "ContactItem"
Set ct = ob
If ((ct.Email1Address = mi.To) Or (ct.Email2Address =
mi.To) Or (ct.Email3Address = mi.To)) Then
Exit Sub
End If
Set ct = Nothing
Case "DistributionList"
'You might want to consider this possibility!
End Select
Next
End If
'If we get this far then we need to cancel the email
MsgBox "Email not sent"
Cancel = True
End Sub
--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"answrtek" wrote:

We are a very small company, using Outlook v.2000 through a web hosting
solution for our email. Email is setup to send and receive perfectly. We do
not have or even know how to use Exchange, and cannot afford it at any rate.
We have 10 or so computers, each with a stand alone version of Outlook v.2000
installed and users have a single email address to send / receive email from.
All computers are Win xp, fully patched.

For security and productivity purposes we want to limit the ability of a user
to send an email from Outlook (with or without attachments) to only those
email addresses that are listed in the contacts folder or ,alternatively we
would like to be able to specify a single domain name that you can send to
and restrict all others. Either approach would work for our purposes, however
the single domain approach would be best. (like @thisdomain.com) for some
users and the contacts better for others (based on position)

I've been able to accomplish a lot of things with Visual basic like this in
the past with almost every other Office application, (Access, Word, Excel,
PowerPoint) yet cannot seem to wrap my mind around how to accomplish this in
Outlook.

Every idea I've tried fails or just doesn't run, even if it compiles ok.
Rules don't seem to have this option and I haven't seen any 3rd party
affordable or even free software that can accomplish this. The only solutions
I seen are for Exchange administrators, and Like I said we do not have or use
Exchange.

To me, using VB Code it seems like I should be able to:

intercept the send command (i.e.- on the send button clicked etc)

compare the TO (and CC and BCC) recipient value in the email to the various
email addresses in the contacts folder (email1Address, email2Address, etc),
looping through all the contacts

and

allow it and send it if it matches (maybe even give a msgbox "Email matched,
send OK)

or

Disallow it if it doesn't (msg box "Sorry this message....etc) vbOkOnly etc
and not let it complete the send command

I'm at a loss. Can anybody help me with the VB code necessary to handle this
kind of event in Outlook? I've been googling and reading online posts for
three days and haven't seen anything that addresses this kind of need.

Seems simple, yet it is driving me a little goofy.

Thankx in advance,

--
Sanity calms, but madness is more interesting. -John Russel


  #4  
Old November 18th 08, 05:01 PM posted to microsoft.public.outlook.program_vba
Alan Moseley
external usenet poster
 
Posts: 61
Default Can I restrict email sent in Outlook without using Exchange?

These lines are where it works out if the recipient is in the Contacts folder:-

If ((ct.Email1Address = mi.To) Or (ct.Email2Address = mi.To) Or
(ct.Email3Address = mi.To)) Then
Exit Sub
End If

Your code needs to be more detailed here. Each email has a recipients
collection, so you need to iterate through these really, for example:-
For Each rc In Mi.Recipients
If (rc.Address=ct.Email1Address) Or (rc.Address=ct.Email2Address) Or
(rc.Email3Address) Then
Exit Sub
End If
Next

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"answrtek" wrote:

I appreciate your help Alan.

At least now I have a beginning that interacts with the send routine. I'll
fiddle with it for a bit and see if I can get it to do what I want it to. At
this point I can see it run line by line, and it is comparing input name in
the TO field versus the data stored in contacts, however it doesn't see a
match with that data even if it appears to be the same.

What can you do , in order to have the code compare an input email address
to a resolved name?

For example in this piece of code:

"ct.Email1Address = mi.To", the input address (mi.To) might be like
" .

Outlook resolves this like "Mike Johnson" on an email.

The Contact folder says Mike Johnson in the full name field.
Which looks like "Mike Johnson*, in the code as it runs, yet the underlying
email1 address = )

I'm missing something.

"Alan Moseley" wrote:

Try pasting this code into your ThisOutlookSession vba window. I haven't
answered your question fully as I could spend all day on this, but it should
be enough for you to work out the remainder. For example you haven't
considered if the recipient is in a distribution list, and my code assumes
that there is only one recipient.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim mi As MailItem
Dim cf As MAPIFolder
Dim ob As Object
Dim ct As ContactItem

If TypeName(Item) = "MailItem" Then
Set mi = Item
'Check if domain matches our chosen one
If Right(mi.To, Len(mi.To) - InStr(mi.To, "@")) = "amitc.co.uk" Then
Exit Sub
End If
'Now check if the recipient is in the contacts folder
Set cf =
Outlook.GetNamespace("MAPI").GetDefaultFolder(olFo lderContacts)
For Each ob In cf.Items
Select Case TypeName(ob)
Case "ContactItem"
Set ct = ob
If ((ct.Email1Address = mi.To) Or (ct.Email2Address =
mi.To) Or (ct.Email3Address = mi.To)) Then
Exit Sub
End If
Set ct = Nothing
Case "DistributionList"
'You might want to consider this possibility!
End Select
Next
End If
'If we get this far then we need to cancel the email
MsgBox "Email not sent"
Cancel = True
End Sub
--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"answrtek" wrote:

We are a very small company, using Outlook v.2000 through a web hosting
solution for our email. Email is setup to send and receive perfectly. We do
not have or even know how to use Exchange, and cannot afford it at any rate.
We have 10 or so computers, each with a stand alone version of Outlook v.2000
installed and users have a single email address to send / receive email from.
All computers are Win xp, fully patched.

For security and productivity purposes we want to limit the ability of a user
to send an email from Outlook (with or without attachments) to only those
email addresses that are listed in the contacts folder or ,alternatively we
would like to be able to specify a single domain name that you can send to
and restrict all others. Either approach would work for our purposes, however
the single domain approach would be best. (like @thisdomain.com) for some
users and the contacts better for others (based on position)

I've been able to accomplish a lot of things with Visual basic like this in
the past with almost every other Office application, (Access, Word, Excel,
PowerPoint) yet cannot seem to wrap my mind around how to accomplish this in
Outlook.

Every idea I've tried fails or just doesn't run, even if it compiles ok.
Rules don't seem to have this option and I haven't seen any 3rd party
affordable or even free software that can accomplish this. The only solutions
I seen are for Exchange administrators, and Like I said we do not have or use
Exchange.

To me, using VB Code it seems like I should be able to:

intercept the send command (i.e.- on the send button clicked etc)

compare the TO (and CC and BCC) recipient value in the email to the various
email addresses in the contacts folder (email1Address, email2Address, etc),
looping through all the contacts

and

allow it and send it if it matches (maybe even give a msgbox "Email matched,
send OK)

or

Disallow it if it doesn't (msg box "Sorry this message....etc) vbOkOnly etc
and not let it complete the send command

I'm at a loss. Can anybody help me with the VB code necessary to handle this
kind of event in Outlook? I've been googling and reading online posts for
three days and haven't seen anything that addresses this kind of need.

Seems simple, yet it is driving me a little goofy.

Thankx in advance,

--
Sanity calms, but madness is more interesting. -John Russel


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I restrict email sent in Outlook without using Exchange? answrtek Outlook and VBA 6 November 21st 08 03:52 PM
Is it possible to restrict Bcc in Exchange 2003 or Outlook 2003 Srinivas.G Outlook - Using Forms 4 July 8th 08 04:39 PM
restrict email No Name Outlook - General Queries 1 April 22nd 08 02:40 AM
Speed issues using items.restrict on exchange David Tongeman Outlook and VBA 6 August 24th 07 06:25 PM
restrict email download size Blake 7 Outlook Express 1 October 6th 06 03:05 AM


All times are GMT +1. The time now is 03:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.