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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending MAPI mail from VB Client app 1

Status
Not open for further replies.

vituja

Programmer
Oct 1, 2003
30
US
Hi All,

I'm trying to interact with our exchange server from within a VB client program. The VB App needs to send a mass mailing to our internal staff. When a button it clicked on the app, it checks the SQL Database and determins who should get this email.

My problem is I keep getting this error from VB:

You do not have permission to log on. [Microsoft Exchange Server Information Store - [MAPI_E_FAILONEPROVIDER(8004011D)]]

The code I'm trying to execute is below and the error happends where it says HERE->. Is there an easy way to send MAPI mail through an specificed account on our exchange server through VB?

------------------------------------------------------
Dim objSession, oInbox, colMessages, oMessage, colRecipients

Dim strServer, strMyMailbox, strProfileInfo

Set objSession = CreateObject("MAPI.Session")


strServer = "CUEXCHANGE"
strMyMailbox = "IUSR_CUNETIISERVER"
strProfileInfo = strServer & vbLf & strMyMailbox

objSession.Logon "IUSR_CUNETIISERVER", "123456", False, True, 0, True, strProfileInfo

Set oInbox = objSession.Inbox
HERE-> Set colMessages = oInbox.Messages
Set oMessage = colMessages.Add()
Set colRecipients = oMessage.Recipients

colRecipients.Add recipient
colRecipients.Resolve

oMessage.subject = subject
oMessage.Text = msg
oMessage.Send

objSession.Logoff
Set objSession = Nothing
 
I think the penultimate parameter should be False not True and I don't think there should be anything in ProfileInfo or you are creating a new profile just for this session and it won't have permission to the target mailbox.

"IUSR_CUNETIISERVER" must be the name of a profile on the client PC, check in Control Panel | Mail | Profiles. The profile must be associated with the correct Exchange Server and mailbox. You shouldn't need to supply a password unless Logon Network Security is set to None in the profile.

objSession.Logon "IUSR_CUNETIISERVER", , False, True, 0, False

Paul Bent
Northwind IT Systems
 
Thanks for the info.

Can I bypass the profile on the client? Our webserver (IIS) has the client profile for outlook. Is there anyway to connect the client VB app to look for the outlook info on a different box other than the one it is running on?


PS:I got this to work using my own profile.

 
Now I'm not clear what you're trying to do. When you said a button is clicked in your VB app I assumed it was running client-side.

If your app is running client-side, it would normally read the default profile name from the registry and use it to logon:

objSession.Logon strProfileName

If the app is running server-side then omit ProfileName and use ProfileInfo to create a temporary profile for the session:

strProfileInfo = CUEXCHANGE" & vbLF & "IUSR_CUNETIISERVER"
objSession.Logon , , , False, , True, strProfileInfo.

Have a look at this KB article:


Paul Bent
Northwind IT Systems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top