Problem while sending mail from Windows service using MSMAPI
-
Hi Friends, when i call a MSMAPI object from a standalone exe in VB .NET, i am able to send a mail. But when i spawn this exe as a process from a windows service, i get an error message while signing on using the MAPI session SignOn() method. I tried using windows service logon as both local system and using my NT logon too. The error message thrown is System.Runtime.InteropServices.COMException (0x800A7D1A): Not supported at MSMAPI.MAPISessionClass.SignOn() at ProcTryMail.tryMail.Pr_SendMail() in D:\Projects\Ems\Backup_Nov17OutSeq\ProcTryMail\tryMail.vb:line 20 My feeling was that some security access is required. The code i have used is: Public Class tryMail Private objMapiSession As MSMAPI.MAPISession Private objMapiMsgs As MSMAPI.MAPIMessages Private i As Boolean Public Sub Pr_SendMail() Try objMapiSession = New MSMAPI.MAPISession() objMapiMsgs = New MSMAPI.MAPIMessages() objMapiSession.SignOn() objMapiMsgs.SessionID = objMapiSession.SessionID objMapiMsgs.Compose() objMapiMsgs.RecipDisplayName = "--give some mail id here--" objMapiMsgs.MsgSubject = "From .NET MAPI" objMapiMsgs.Send() objMapiSession.SignOff() Catch End Try End Sub End class Will be grateful if anyone of u is able to find out the problem. Thanks Alex
-
Hi Friends, when i call a MSMAPI object from a standalone exe in VB .NET, i am able to send a mail. But when i spawn this exe as a process from a windows service, i get an error message while signing on using the MAPI session SignOn() method. I tried using windows service logon as both local system and using my NT logon too. The error message thrown is System.Runtime.InteropServices.COMException (0x800A7D1A): Not supported at MSMAPI.MAPISessionClass.SignOn() at ProcTryMail.tryMail.Pr_SendMail() in D:\Projects\Ems\Backup_Nov17OutSeq\ProcTryMail\tryMail.vb:line 20 My feeling was that some security access is required. The code i have used is: Public Class tryMail Private objMapiSession As MSMAPI.MAPISession Private objMapiMsgs As MSMAPI.MAPIMessages Private i As Boolean Public Sub Pr_SendMail() Try objMapiSession = New MSMAPI.MAPISession() objMapiMsgs = New MSMAPI.MAPIMessages() objMapiSession.SignOn() objMapiMsgs.SessionID = objMapiSession.SessionID objMapiMsgs.Compose() objMapiMsgs.RecipDisplayName = "--give some mail id here--" objMapiMsgs.MsgSubject = "From .NET MAPI" objMapiMsgs.Send() objMapiSession.SignOff() Catch End Try End Sub End class Will be grateful if anyone of u is able to find out the problem. Thanks Alex
OK. When you run the project as a standalone .EXE, do you get a dialog box when you execute the SignOn method? You should, because that is the default behavior for the Session control. Problem is, as a service, there is no desktop, and therefor no user interface to display a dialog box. You might want to try setting the LogonUI property of the control to FALSE and setting the UserName and Password properties before you call SignOn. RageInTheMachine9532
-
OK. When you run the project as a standalone .EXE, do you get a dialog box when you execute the SignOn method? You should, because that is the default behavior for the Session control. Problem is, as a service, there is no desktop, and therefor no user interface to display a dialog box. You might want to try setting the LogonUI property of the control to FALSE and setting the UserName and Password properties before you call SignOn. RageInTheMachine9532
Thanx RageInTheMachine9532. Setting the LogonUI property to false solves the problem. :)