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

Stopping Dialog boxes in Outlook

Status
Not open for further replies.

BajanPOET

Programmer
Jul 12, 2002
194
BB
Hey guys...

I've created some VBA code to automatically email my boss using Outlook when any member of staff adds a record to the requisitions table in Access. The same code is used to send an acknowledgement from my boss back to the sender of the original email. My problem is that when the code is excuted from within Access, the Outlook virus and spyware blocking capabilities of Outlook kick in - it brings up a dialog box telling the user that another program is trying to use it to send an email. How do I stop this so that the emails are sent seamlessly and the users do not have to be clicking an Ok button several times to allow emails to be sent?

GOD is in charge, though men may say, "Not so!
 
Do a google search for outlook object model guard

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks! I wasn't sure how to start searching for what I needed!

GOD is in charge, though men may say, "Not so!
 
I've done some research on this Outlook Object model guard...but I can't find a suitable workaround. So I've decided to live with it, if I can get it to only prompt the user once!

I have this piece of code I found to send mail from my app through Outlook, but when I run it, the app prompts the user about 4 different times before it goes through. If I have to prompt the user, at least let me do it just once! Any ideas as to what I may be doing wrong?

Code:
Public Sub SendMail(EmailAddress As String, Subject As String, Body As String)
' This routine will work will all incarnations of VBA
' Use Outlook to send email msg
Dim myOutlook As Object
    Dim myMailItem As Object
    ' Make instance
    Set myOutlook = CreateObject("Outlook.Application")
    ' Make mail item
    Set myMailItem = myOutlook.CreateItem(0)
    ' Set recipient (external mail)
    myMailItem.Recipients.Add EmailAddress
    ' Set subject
    myMailItem.Subject = Subject
    ' Set body
    myMailItem.Body = Body
    ' And send it!
    myMailItem.Send
    ' Close instance
    Set myOutlook = Nothing
End Sub

Use of the code is like
Call Sendmail("rgibson@whereever.com","test","this is a test.")

What? Who? ME????
 
Replace this:
myMailItem.Send
with this:
myMailItem.Display

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Ok... this opens up the Outlook message I built using the code so that I can send it from within Outlook. It's not exactly what I had in mind, but it does get rid of the multiple clicking on the button... thanks!

What? Who? ME????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top