Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Due to the 3rd-party security package we use, my app needs to run as Admin. However, it also needs to be able to send emails.

Currently, I'm using MAPISendMail, and it works as desired when logged in with Admin privileges. The issue is that, if logged into a normal User account and the Admin account on the PC doesn't have an email client installed (a very real possibility for our users), it fails.

Is there some way to get the MAPISendMail to run using the account of the non-Admin user who started it? I know I could try to have my program act as its own SMTP server, but this application will be running behind corporate firewalls that I'm certain would block that avenue.

I've been poking around online for several hours now and haven't been able to find anything pertinent to my situation. Can anyone here provide any guidance?

Thanks...Tom
-----------------------------------
Dave - as I noted, my concern is that corporate firewalls will block my program from acting as a mail server, and trying to get their IT departments to allow an exception can be a quagmire. So it seems easier to use the existing (IT-approved) email client. I'll also admit that this approach eliminates the need for my program to request and store mailserver name, port, etc. info, which I'd prefer to leave to other programs that do that very well.

Maybe I just need to bite the bullet, turn my program into a mail server, and let users deal with their IT people if they have problems? Not very customer-friendly though.
Posted
Updated 16-Mar-12 2:38am
v3
Comments
sjelen 16-Mar-12 9:30am    
Using System.Net.Mail does not turn your app into SMTP server. You can use it to make your app act as mail client, just set it up with same SMTP parameters you would use to configure the standalone email client (smtp server address, user credentials).
tzych 16-Mar-12 13:53pm    
Thanks - I was apparently misunderstanding how SmtpClient worked. I tested that approach, and it works so far! Bad news is I need to have my users provide their mail server info, store that, etc. - but better than having to remove the feature...

Hi,

you can change requestedExecutionLevel in your app.manifest file to
requireAdministrator , but users have to accept dialog from UAC

C#
<requestedexecutionlevel level="requireAdministrator" uiaccess="false" />


Does it work for you?

Regards
 
Share this answer
 
v3
Why are you using MAPISendMail when there is a SMTP client build into the .NET Framework??

System.Net.Mail[^] namespace
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900