Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Problem while sending mail from Windows service using MSMAPI

Problem while sending mail from Windows service using MSMAPI

Scheduled Pinned Locked Moved Visual Basic
helpcsharpdockersecurity
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alexander132
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • A alexander132

      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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      A 1 Reply Last reply
      0
      • D Dave Kreskowiak

        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

        A Offline
        A Offline
        alexander132
        wrote on last edited by
        #3

        Thanx RageInTheMachine9532. Setting the LogonUI property to false solves the problem. :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups