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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide Outlook Message Window

Status
Not open for further replies.

RClarkeJr

Programmer
Nov 10, 2004
20
US
Hello All,

I have created a webpage which uses the following VBScript and then prefills the email with the information and sends it. Why am I doing this? Our Fax Server requires users to use the correct switches and format, and since they are unable to do this, I created an interface thru a webpage which makes it much easier for them. But I do not want them to see the email. I want outlook to send it in the background.

Set WSHShell = CreateObject("WScript.Shell")
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.display
myItem.To = ToText
ConstSubject = document.FORM1.txtSubject.value
myItem.Subject= ConstSubject
myItem.Body = chr(13) & chr(13) & ConstComment
myItem.Save
Set myAttachments = myItem.Attachments
myAttachments.Add FileNames
WSHShell.AppActivate myItem
WSHShell.SendKeys ("%(s)")

Thank You.
 
Have you tried this (typed, untested):
myOlApp.Visible = False

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
i would say PHV is right.
also, are you sure the sendkeys is nec? or are you doing it to avoid that horrid, 'someone is using your email address blaa blaa'
 
PHV,

I tried visible = false, and it indicates the object doesn't support this property.

MrMovie,
I am using the sendkeys to send the email and prevent that nasty message.
 
And this ?
myOlApp.ActiveWindow.windowstate=1

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

No Effect. I also tried myOlApp.ActiveWindow = 1.
 
i think in outlook you might need to try something like

myOlApp.ActiveWindow.WindowState = 1

you may also find that if you succeed in 'hiding' the mail item the AppActivate will stop working but thats just a guess
 
am i a dumb arse or what, sorry PHV didnt see that post. too early in the morning.
i have tested the code and it does Minimize the window.
 
What i have done in the past is remove the

myItem.display

then it won't be visible!

Then instead of 'WSHShell.SendKeys ("%(s)")'

Use

myitem.send

hope this helps!
 
teckiejon,

I commented out the myItem.display, and the sendkeys, and added myItem.Send.

Here is the problem, I get that nasty message which says 'someone is using your email address'. I do not want the user to see this box either. I want it all to be transparent.

Thanks for the suggestion though.
 
do you have an smtp server available?
when i want to send an email from a users machine i use cdo and smtp and then the user knows nothing about it. whats more you dont have to worry about outlook sessions.
on the down side you dont get it in their sent items. but you might find you can spoof a sent item and it wont chuck up the nasty message.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top