Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restrict sending emails only to a specific SMTP address 1

Status
Not open for further replies.

jmurfin

IS-IT--Management
Jan 12, 2005
32
0
0
US
Hi All,

I have a request from a manager that wants a specific-use login account that does nothing but launch Outlook and can send emails only to a specific SMTP address - nowhere else. I can't see anywhere in my Exchange 2003 SP1 / OL2003 setup where I can restrict the outbound email like this. I can launch a pre-created .oft file, but the user could easily change the recipient field.

Any ideas?

Thanks!
Jeff
 
There may be a better way - have you asked why? Sounds like an SMTP scripted event would be better than a MAPI client.
 
Thanks for your reply, Zelandakh.

Yes, I think a script is a good way to go with this one, but was hoping to avoid that, as I don't have good scripting skills. The user would also have to add a picture attachment before they send it.

Thanks,
Jeff
 
Yes, but WHY?

Can't this be done as a rule from someone else's mailbox using a server side rule? That would do the trick for you for sure, but I'm struggling to understand the rationale on this.
 
Scripting it is a breeze. Working remotely right now. Will post the code for you later today or tomorrow morning.

I hope you find this post helpful.

Regards,

Mark
 
I've got a similar issue and I've a pretty good feeling you could use an Exchange SMTP connector just for that address, then restrict the user to only use that connector and no other. I haven't worked out exactly how to do it yet, my requirements are slightly different, I have a range of users that I want to restrict to a range of addresses, all in one external domain.

See my other recent post.

Let me know if you work it out, I'll do the same.

Andy.
 
OK, here you go. This should do all that you want in a fairly easy fashion. Save the following script to the users desktop. Have them type a text message to be sent out using notepad and put the text file in the same directory as the script. You also need to put the disclaimer text file in the same directory. Double click the the script and you will be prompted for the subject and attachment information and away it goes. You will need to authorize the IP of the users machine to relay through your SMTP server. Because of this, make sure you have AV software running on the PC for safety.

Areas you must change are in [red]RED[/red].

Code:
[green]
'==========================================================================
' NAME: EmailAttachment.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 4/23/2004
'
' COMMENT: 
'
' You must customize the entries for oTo, oFrom and oMyIP with the proper company information.
'=====================================[/green]
On Error Resume Next 
Dim OFrom, oMyIP, oTo, oFSO, oFirstName, TheMessage, Disclaimer
Const ForReading = 1
Set oFSO=CreateObject("Scripting.FileSystemObject")
[green]
' Set the visual basic constants as they do not exist within VBScript.
' Do not set your smtp server information here.[/green]
Const cdoSendUsingMethod = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing",[/URL] _
cdoSendUsingPort = 2, _
cdoSMTPServer = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver"[/URL]
[green]
'*************************************************
' Set the company specific information
'*************************************************
' Company Email Address[/green][red]
OFrom = "info@yourcompany.com"[/red][green]
' Set the SMTP server IP [/green][red]
oMyIP = "192.168.1.2" [/red][green]
'Where do you want to send it to?[/green][red]
oTo= customer@company.com[/red]
[green]
'Read the message to be sent[/green]
mPrompt = InputBox("What is the name of the message file?" & vbCrlf & "Example: bigsale.txt")
mSubject= InputBox("What should the Subject of the message be?" & vbCrlf & "Example: Don't miss the big sale!!!")
mAttach = InputBox("Do you want to send an attachment?" & vbCrlf & "Type the file name here or just click OK for no attachment." & vbCrlf & "Example: bigsale.jpg")
	
TheMessage = ofso.OpenTextFile(mPrompt, ForReading).ReadAll

Disclaimer=ofso.OpenTextFile("disclaimer.txt", ForReading).ReadAll

TheMessage = TheMessage & vbCrLf & Disclaimer
[green]
'Create the CDO connections.[/green]
Dim iMsg, iConf, Flds
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
[green]
'SMTP server configuration.[/green]
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
[green]
'// Set the SMTP server address here.[/green]
.Item(cdoSMTPServer) = oMyIP
.Update
End With
[green]
'Set the message properties.[/green]
With iMsg
Set .Configuration = iConf
.To = oTo
.From = oFrom
.Subject = mSubject
.TextBody = TheMessage
End With
[green]
'An attachment can be included.[/green]
If Len(mAttach)>0 Then
iMsg.AddAttachment mAttach
End If
[green]
'Send the message.[/green]
iMsg.Send 

MsgBox "Message Sent"

Here is the disclaimer text. Modify it as you see fit. Save this to a text fiel called disclaimer.txt and put it in the same directory as the script.

Code:
END MESSAGE


The following statement is provided to be 
in compliance with commercial email laws.


If you do not wish to receive further
mailings, please send an email to:

NOMORE@YOURCOMPANY.COM 

with REMOVE typed in the subject line.

This message is in full compliance with
U.S. Federal requirements for commercial
email under bill S.1618 Title lll, Section 301,
Paragraph (a)(2)(C) passed by the 105th U.S.
Congress and is not considered SPAM
since it includes a remove mechanism.*
This message is not intended for residents in the
states of CA, NC, NV, RI, TN, VA & WA. 
Screening of addresses has been done to the best
of our technical ability.

Thank you

I hope you find this post helpful.

Regards,

Mark
 
Hi Mark,

Thanks so much for this code! I am anxious to try it out for my project. You've been very helpful - thanks again!

- Jeff
 
Always happy to help.

If your user is smart enough to be able to do html by hand (or by using ms word whatever)I also have the code needed to send html emails. let me knwo if you want that.

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top