473,394 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

E-Mailing through outlook

Hi

Is there a way to e-mail using outlook2002 from within vb.net without
getting the nasty "An application is trying to access you outlook..."
message?

Thanks

Regards
Nov 20 '05 #1
14 6931
John

you can't prevent the Outlook dialog, but you can write
code to fill it in programmatically so it only appears
for an instant. It needs to run in a separate thread but
VB.Net can do that easily enough.

I have code for this

Dermot Balson
Free VBA code for user interfaces, internet connectivity,
encryption
http://www.webace.com.au/~balson/Ins...l/Default.html
Last updated August 2003
-----Original Message-----
Hi

Is there a way to e-mail using outlook2002 from within vb.net withoutgetting the nasty "An application is trying to access you outlook..."message?

Thanks

Regards
.

Nov 20 '05 #2
John,
Outlook 2003 has changed the rules such that properly constructed COM Addins
will no longer get the prompt.

http://www.slipstick.com/dev/ol2003problems.htm

I have not tried it, it sounds like Exchange Server has options to control
the prompt on earlier versions of Outlook.
http://www.slipstick.com/dev/ol2003problems.htm
http://www.slipstick.com/outlook/esecup/admin.htm

In case you don't have it the following site provides a number of articles
on using Outlook from .NET.

http://www.microeye.com/resources/res_outlookvsnet.htm

Hope this helps
Jay

"John" <jo**@nospam.infovis.co.uk> wrote in message
news:uB**************@tk2msftngp13.phx.gbl...
Hi

Is there a way to e-mail using outlook2002 from within vb.net without
getting the nasty "An application is trying to access you outlook..."
message?

Thanks

Regards


Nov 20 '05 #3
Why not just use the SmtpMail class and send it through whatever server
Outlook uses?
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:uB**************@tk2msftngp13.phx.gbl...
Hi

Is there a way to e-mail using outlook2002 from within vb.net without
getting the nasty "An application is trying to access you outlook..."
message?

Thanks

Regards


Nov 20 '05 #4
Keeping a record in outlook is handy for future reference. In this way all
emails sent either from the app or from outlook remain in the same place.

Regards
"Stephen" <gr******@bellatlantic.net> wrote in message
news:es**************@tk2msftngp13.phx.gbl...
Why not just use the SmtpMail class and send it through whatever server
Outlook uses?
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:uB**************@tk2msftngp13.phx.gbl...
Hi

Is there a way to e-mail using outlook2002 from within vb.net without
getting the nasty "An application is trying to access you outlook..."
message?

Thanks

Regards


Nov 20 '05 #5
Hi Dermot

That is great. Would it be possible to post the code?

Thanks

Regards

"dermot" <de********************@hotmail.com> wrote in message
news:0e****************************@phx.gbl...
John

you can't prevent the Outlook dialog, but you can write
code to fill it in programmatically so it only appears
for an instant. It needs to run in a separate thread but
VB.Net can do that easily enough.

I have code for this

Dermot Balson
Free VBA code for user interfaces, internet connectivity,
encryption
http://www.webace.com.au/~balson/Ins...l/Default.html
Last updated August 2003
-----Original Message-----
Hi

Is there a way to e-mail using outlook2002 from within

vb.net without
getting the nasty "An application is trying to access

you outlook..."
message?

Thanks

Regards
.

Nov 20 '05 #6
Hi Stephen, John,

Or you could do both. Send it with SmtpMail and use Outlook Automation to
stuff a copy in the Sent folder.

Regards,
Fergus
Nov 20 '05 #7
If it can be done in one step then obviously it is the preferable choice.
Normally sending an email via outlook will do both in one go.
"Fergus Cooney" <fi******@tesco.net> wrote in message
news:uH*************@TK2MSFTNGP11.phx.gbl...
Hi Stephen, John,

Or you could do both. Send it with SmtpMail and use Outlook Automation to stuff a copy in the Sent folder.

Regards,
Fergus

Nov 20 '05 #8
Hi John,

I agree - one step is better than two steps. But if two steps are needed
to get around that pesky dialogue, then let's go dancing!

Dermot's solution sounds interesting. An alternative is a wonderful little
utility called "Push The Freakin' Button" which can look out for given
dialogues and press a specific button. It's on many download sites.
Unfortunately, the source isn't available for this one either. :-(

Regards,
Fergus
Nov 20 '05 #9
Cor
Fergus,
What John does is his own decision.
But I find it always wrong to fill up an exchange server with mail that is
batch mail.
When you send mail using Outlook then every independent mail message is
stored in the exchange server. The send address is always the same and only
the address from the receiver is different, but that is bad traceable with
only the Exchange server.
I find it much nicer to keep that information in let's say a CRM system by
instance on a SQL server.
Than you only have to keep one mail and the information to whom you did send
that.
The SMTP mail server is not made for nothing.
But it's of course a matter of taste.
You know, some like the tango others the quickstep.
:-)
Cor
Nov 20 '05 #10
Howdy Cor - Good afternoon now!!

Isn't it nice to be able to 'converse' again without having to wait
several hours and then be afraid to click on a message in case it disappears!!

I agree that storing multiple copies of a mail is silly, however I don't
believe this is John's intention.

|| You know, some like the tango others the quickstep.

LOL. And others have a style involving drumsticks and a lot of space which
can't* be named!! ;-))

Cheers,
Fergus

* Actually I'm sure many people <have> got a name for it but I'm not going to
let that put me off!!
Nov 20 '05 #11
Here is my code to kill the Outlook permission dialog

I am still learning Vb.Net, my experience is in Excel VBA
& VB, so the code could probably be improved. It launches
a second thread that looks out for the dialog, before the
primary thread accesses Outlook

Dermot Balson
Free VBA code for user interfaces, internet connectivity,
encryption
http://www.webace.com.au/~balson/Ins...l/Default.html
Last updated August 2003

***** this is the bit that runs the class ****
Dim OK As New oKiller
OK.SearchAndDestroy()
'Your code to access Outlook follows here
'CODE
'it will trigger the dialog, and the killer class should
'deal with it
'when you have finished, you can stop the killer class
like this
OK.Quit
'it is timed to quit after 15 min anyway, because it
gives permission for one minute only, and the dialog may
come up more than once

*********************************************

***** the class follows **********************

'When you access Outlook folders, a permissions dialog
pops up. This class fills in the dialog for the user

Imports System.Threading

Public Class oKiller

#Region "Declarations"
Private Const GW_HWNDNEXT = 2
Private Const GW_CHILD = 5
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const SC_RETURN = &H1C
Private Const BM_SETCHECK = &HF1
Private Const BST_CHECKED = &H1&
Private Const KEYEVENTF_KEYUP = &H2

Private Declare Sub keybd_event Lib "user32" (ByVal bVk
As Byte, ByVal bScan _
As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo
As Integer)
Private Declare Function GetForegroundWindow
Lib "user32" () As Integer
Private Declare Function GetDesktopWindow Lib "user32"
() As Integer
Private Declare Function GetWindow Lib "user32" _
(ByVal hwnd As Integer, ByVal wCmd As Integer) As
Integer
Private Declare Function GetWindowText Lib "user32"
Alias "GetWindowTextA" _
(ByVal hwnd As Integer, ByVal lpString As String,
ByVal cch As Integer) As Integer
Private Declare Function GetClassName Lib "user32"
Alias "GetClassNameA" _
(ByVal hwnd As Integer, ByVal lpClassName As String,
_
ByVal nMaxCount As Integer) As Integer
Private Declare Function SetForegroundWindow
Lib "user32" _
(ByVal hwnd As Integer) As Integer
Private Declare Function SendMessage Lib "user32"
Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg
As Integer, ByVal wParam As Integer, ByVal lParam As
Integer) As Integer
Private Declare Function BringWindowToTop Lib "user32"
(ByVal hwnd As Integer) As Integer
Private Declare Sub Sleep Lib "kernel32" (ByVal
dwMilliseconds As Integer)
Private Declare Function PostMessage Lib "user32"
Alias "PostMessageA" (ByVal hwnd As Integer, ByVal wMsg
As Integer, ByVal wParam As Integer, ByVal lParam As
Integer) As Integer
#End Region

Dim hDialog As Integer
Dim hCheckbox As Integer
Dim hButton As Integer
Dim FoundhWnd As Integer
Dim PrevhWnd As Integer

Dim t As System.Threading.Thread

'this is the public method used to start this class
Public Sub SearchAndDestroy()

'it needs to be on a separate thread because the main
thread is waiting
'for Outlook to respond, and for the same reason it
needs to be launched
'just before the main thread accesses the Outlook
folders
'this method will run the thread for up to 60
seconds, waiting for the
'dialog window to appear
t = New System.Threading.Thread(AddressOf LieInWait)
t.Start()

End Sub

'this method looks for the dialog window every split
second, for 15 minutes, then exits
Private Sub LieInWait()

Dim Counter As Integer
Dim u As Boolean

Do
'search every 0.25 seconds
Thread.CurrentThread.Sleep(250)
u = SearchForWindow()
Counter += 1
Loop While Counter < 3600

End Sub

'this method allows the main thread to terminate this
class when it is not needed
'any more
Public Sub Quit()

t.Abort()

End Sub

'this function does most of the work, waiting for the
dialog to appear
Private Function SearchForWindow() As Boolean

Dim hwnd As Integer
Dim t As Single, r As Integer, t2 As Single
Dim sWindowText As String, sClassname As String

'has the active window changed?
hwnd = GetForegroundWindow
If hwnd <> PrevhWnd Then

'get the window and class names
sWindowText = Space(255)
r = GetWindowText(hwnd, sWindowText, 255)
sWindowText = Left(sWindowText, r)

sClassname = Space(255)
r = GetClassName(hwnd, sClassname, 255)
sClassname = Left(sClassname, r)

'Check that window matches the search parameters
If (sClassname = "#32770") And sWindowText
= "Microsoft Outlook" Then
hDialog = hwnd
'get the dialog details and kill it
KillDialog()
SearchForWindow = True
'try to restore previous app that was in front
SetForegroundWindow(PrevhWnd)
Exit Function
End If
End If

'remember current active window
PrevhWnd = hwnd

End Function

'this method kills the Outlook dialog
'it has the handle of the dialog
Private Sub KillDialog()

'get handles of controls on form
FindWindowLike(hDialog)

'exit if we didn't find any handles
If hCheckbox = 0 Or hButton = 0 Then Exit Sub

'tick checkbox
Call SendMessage(hCheckbox, BM_SETCHECK, BST_CHECKED,
0&)

'press Yes button
PostMessage(hButton, WM_LBUTTONDOWN, 0, 5) ' wParam,
lParam = x,y
Sleep(50)
PostMessage(hButton, WM_LBUTTONUP, 0, 5)
Sleep(50)
'pass an Enter keystroke as well because sometimes
clicking the button is
'not enough to make the dialog disappear
Call keybd_event(13, 0, 0, 0)
Call keybd_event(13, SC_RETURN, KEYEVENTF_KEYUP, 0)

End Sub

'this function finds all the child windows and is used
to get the
'handles of the child controls on the Outlook dialog
Private Function FindWindowLike(ByVal hWndStart As
Integer) As Integer

Dim hwnd As Integer
Dim sWindowText As String
Dim sClassname As String
Dim r As Integer

'Hold the level of recursion and
'hold the number of matching windows

'Initialize if necessary
If hWndStart = 0 Then hWndStart = GetDesktopWindow()

'Get first child window
hwnd = GetWindow(hWndStart, GW_CHILD)

Do Until hwnd = 0

'Search children by recursion
Call FindWindowLike(hwnd)

'Get the window text and class name
sWindowText = Space(255)
r = GetWindowText(hwnd, sWindowText, 255)
sWindowText = Left(sWindowText, r)

sClassname = Space(255)
r = GetClassName(hwnd, sClassname, 255)
sClassname = Left(sClassname, r)

'look for Yes button and access dropdown
Select Case sWindowText
Case "Yes"
hButton = hwnd
Case "&Allow access for"
hCheckbox = hwnd
End Select

'Get next child window
hwnd = GetWindow(hwnd, GW_HWNDNEXT)

Loop

FindWindowLike = 0

End Function

End Class
Nov 20 '05 #12
Hi Dermot,

Thanks for the reminder of the link I went there previously and looked at
everything but couldn't find any code. It's clear that Excel is powerful
beyond the obvious, as is your knowledge of it - the Web Server!! for example.
And on the same page is your OutKill2.exe.

Is this just the utility or is it the code too? I downloaded it but WinZip
saw nothing so I guess it's not a zip2exe. I'm thinking that John would like
the source so that he can incorporate its method into his program, and I am
interested in this too, as a generally useful method.

Is the source there but I just didn't see it? If not, would you mind us
having a look at it?

Thanks.

Regards,
Fergus
Nov 20 '05 #13
Fergus

sorry about the delay. My site only has the EXE on it, but I did
include the (VB.NEt) source in the message you just replied to ,and
you are free to use it. After all, I put it together from code I'd
borrowed from other people!

regards

dermot

"Fergus Cooney" <fi******@tesco.net> wrote in message news:<ub**************@tk2msftngp13.phx.gbl>...
Hi Dermot,

Thanks for the reminder of the link I went there previously and looked at
everything but couldn't find any code. It's clear that Excel is powerful
beyond the obvious, as is your knowledge of it - the Web Server!! for example.
And on the same page is your OutKill2.exe.

Is this just the utility or is it the code too? I downloaded it but WinZip
saw nothing so I guess it's not a zip2exe. I'm thinking that John would like
the source so that he can incorporate its method into his program, and I am
interested in this too, as a generally useful method.

Is the source there but I just didn't see it? If not, would you mind us
having a look at it?

Thanks.

Regards,
Fergus

Nov 20 '05 #14
Hi Dermot,

ROFL. Small window in OE - Message, Signature, Link - End of perusal.
Missed it!!

Got it now, though - excellent.

Thanks.:-))

Regards,
Fergus
Nov 20 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: MLH | last post by:
I print to a device that creates a PDF. Knowing the filename, how can I then embed the PDF into the body text of an OutLook Express outbound email & send to a specified address in a table? I want...
2
by: Ronnie | last post by:
I am faced with quite a conundrum. I have been assigned to develop a contact database, that can be queried using many different criterion. Now the hardest part is, my clients want to view the...
3
by: Strasser | last post by:
In Access2000 mass emailing worked perfectly (very powerful tool!). Doesn't work when using XP version of both Access and Outlook, even though I checked the box to ensure that I was sending the...
2
by: Wayne | last post by:
I am experiencing an intermittent problem when emailing snapshot reports using Sendobject. Outlook opens with the snapshot of the report attached but when I click the "Send" button on the Outlook...
5
by: adrian.williams2 | last post by:
Hi, I'm having trouble trying to email a report via access... I get a Outlook message stating 'a program is trying to automatically send e-mail on your behalf. Do you want allow this? This...
4
by: Mike Moore | last post by:
What is the best way to launch outlook from an asp.net web page? Can you do this using MAPI or is there a control that you can purchase? We are unable to use SMTP. We use MS Exhange and MAPI...
8
by: John | last post by:
Hi I am using the latest redemption. I am using the below code in vb.net to send mail in html format. The problem is that text does not get sent as html and html tags appear as they are in the...
11
by: Liam.M | last post by:
Hey guys, If anyone could spare sometime to help me out, it would be very much appreciated.....what I am trying to do is automate a "Command" that sends me an Email. I have created a Query that...
8
by: marjbell | last post by:
I have a Access database of email addresses that I would like to mass email to customers. Can Access be used through Outlook? or can it just be done with Access? I know it is possible to use...
12
by: JohnClingeleffer | last post by:
I use VBA in MS Access to send e-mails. Relevant code for error is: Set oItem= objOL.CreateItem(0) ' Const olMailItem With oItem errMsg = "Error populating Microsoft Outlook mail item...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.