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!

Outlook Namespace Logoff command not working

Status
Not open for further replies.

pokasick

Programmer
Oct 29, 2001
17
US
Hi,

I’ve got a VB6 program that logs on to Outlook under a certain profile, checks that the username is correct, sends an email, then logs off and quits the application. The profiles are local on the machine. I have a reference set to the Microsoft Outlook 9.0 Object Library. When the 2nd program logs in under a different profile, there is no problem.

The same scenario with my .NET program causes a problem. The .NET program sends the email as expected, but does not seem to log off from the namespace even though I'm issuing the logoff and quit commands. When the 2nd program logs on, it’s failing the check of the username because the .NET program has not logged off properly. We have many VB6 programs using similar email code every day. We're just moving to .NET now.

Has anyone had anything like this happen? Any ideas or directions to look? The .NET code is below.

Client Version: Outlook 2000 9.0.0.2711
Server Version: Exchange Server 2000 SP3

Thanks,
Paul

Public Sub SendErrorEmail(ByVal p_sSubject As String, ByVal p_sBody As String)
Dim objOutLk As Outlook.ApplicationClass
Dim objOutLkNmSpc As Outlook.NameSpaceClass
Dim sOutLkProfile As String
Dim sOutLkUserID As String

sOutLkProfile = "SystemsGroup"
sOutLkUserID = "SystemsGroup"

objOutLk = New Outlook.ApplicationClass()
objOutLkNmSpc = objOutLk.GetNamespace("MAPI")
objOutLkNmSpc.Logon(sOutLkProfile, sOutLkUserID, False, True)

With objOutLk.Application.CreateItem Outlook.OlItemType.olMailItem)
.Recipients.Add(g_sEmailAddress)
.Subject = p_sSubject
.Body = p_sBody
.Send()
End With

objOutLkNmSpc.Logoff() ‘This line works in VB6
objOutLk.Quit()

objOutLkNmSpc = Nothing
objOutLk = Nothing

End Sub 'SendErrorEmail


Code from the 2nd program:

objOutLkNmSpc.Logon sOutLkProfile, sOutLkUserID, False, True
If objOutLkNmSpc.CurrentUser.Name <> sOutLkUserID Then
Throw an error…
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top