-
I'm using MAPI to send mail via MS Exchange Server. I've setup a Mail profile in Control Panel, and when I send mail from Outlook Express, everything works fine.
However, when I try to use send mail from my VB app, I get the error message "Login Failed", even though my MAPISession has been started with no error and its SessionID property has been assigned to the equivalent property of my MAPIMessages control.
Any ideas?
Nahid Harjee
-
Hello?
-
Can you post your source code?
-
Here's my code (it's part of one of my classes):
Private Const LDT_profile = "LDT"
Private Sub Class_Initialize()
With frmContainer.MAPISess
.DownLoadMail = False
.LogonUI = False
.NewSession = True
.UserName = LDT_profile
.SignOn
frmContainer.MAPIMess.SessionID = .SessionID
End With
End Sub
Private Sub Class_Terminate()
frmContainer.MAPISess.SignOff
End Sub
Public Sub sendMail()
With frmContainer.MAPIMess
.Compose
.RecipAddress = "[email protected]"
.MsgSubject = "Test"
.MsgNoteText = "Test"
.Send
End With
End Sub
The sendMail method fails on the frmContainer.MAPIMess.Send method with either the error: Login has failed or Unspecified Error.
Any help would be greatly appreciated.
Nahid Harjee
-
PROBLEM SOLVED!
Don't worry about it, I've figured out the problem.
For some reason, with one-off messaging (ie. sending messages to users not in an address book), you must specify the e-mail address of the recipient in the RecipDisplayName property and not in the RecipAddress property.
So, it should be:
.RecipDisplayName = "[email protected]"
Don't ask me why, it's completely counter-intuitive. Ask M$.
Nahid Harjee
-
Yes, I had this problem before too.
Another solution to it is to load Outlook Address book.
Here is the code:
.MsgIndex = -1
.AddressEditFieldCount = 2
.Compose
.Show False
.ResolveName
.AddressResolveUI = True
Anna Carlen