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

email error

Status
Not open for further replies.

vlitim

Programmer
Joined
Sep 2, 2000
Messages
393
Location
GB
I have a form that emails a person. It works fine for most people but one person always gets this error:

run-time error: 32003
Login has failed

any idea what might cause this?

Cheers
Tim
 
You will have to provide a little more information. What email client. How are you doing it through code? Can this person use this same email client outside of your application?
 
the email client is outlook and I am using the microsoft MAPI tools to connect to it. All I am trying to do is send mail, no recieving or anything like that. It has worked fine on all other computers I have tested it on, and everyone is set up pretty much the same.
 
Hey try to attach ur code, then i can help you
 
body = "A job has been Added/Ammended to your Todo list" & vbCrLf & "" & vbCrLf & "Client: " & clientName & "" & vbCrLf & "Name: " & jobname & "" & vbCrLf & "Description: " & jobDescription & ""

MAPISession1.SignOn
MAPIMessages1.SessionID = MAPISession1.SessionID

MAPIMessages1.Compose
MAPIMessages1.RecipAddress = emailto
MAPIMessages1.ResolveName


MAPIMessages1.MsgSubject = "TO DO - Jobs"
MAPIMessages1.MsgNoteText = body

MAPIMessages1.Send False

MAPISession1.SignOff
 
did this problem get solved as I have the same issue. Think it's to do with the fact the the person who's machine it doesn't work on has Service Pack 3 for office on, while the others all have service pack 1.
 
This can happen when LogonUI is set to false and UserName is Null when SignOn is called. Read the default profile from the registry and assign it to the UserName property before calling SignOn. The default profile is stored under:

W95/98/ME
HKCU\Software\Microsoft\Windows Messaging Subsystem\Profiles\DefaultProfile

NT/2000/XP
HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\DefaultProfile

Paul Bent
Northwind IT Systems
 
I've tried this using GetSetting. Getsetting simply returned the default, when I look in the registry under the path, the data value says 'MS Exchange Settings'. Show this show the current user? or does the registry not allow me to see the details.
 
GetSetting only works on HKEY_CURRENT_USER\Software\VB and VBA Program Settings - you'll need to use API to get the setting.

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
 
Paste this lot into a module:
Code:
Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long

Public Function GetKeyValue(strKey As String, strValue As String) As String
  Const cstrRoutineName As String = "GetKeyValue"
  Const clngHKCU As Long = &H80000001
  Const READ_CONTROL = &H20000
  Const KEY_QUERY_VALUE = &H1
  Const KEY_SET_VALUE = &H2
  Const KEY_CREATE_SUB_KEY = &H4
  Const KEY_ENUMERATE_SUB_KEYS = &H8
  Const KEY_NOTIFY = &H10
  Const KEY_CREATE_LINK = &H20
  Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
                       KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
                       KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
  ' Return code constants
  Const ERROR_NONE = 0
  Const ERROR_BADDB = 1
  Const ERROR_BADKEY = 2
  Const ERROR_CANTOPEN = 3
  Const ERROR_CANTREAD = 4
  Const ERROR_CANTWRITE = 5
  Const ERROR_OUTOFMEMORY = 6
  Const ERROR_ARENA_TRASHED = 7
  Const ERROR_ACCESS_DENIED = 8
  Const ERROR_INVALID_PARAMETERS = 87
  Const ERROR_NO_MORE_ITEMS = 259
  
  Dim lngR As Long ' Resultcode
  Dim lngH As Long ' Handle
  Dim strX As String ' returned value
  Dim lngX As Long ' returned length
  Dim lngT As Long ' Key type

  lngR = RegOpenKeyEx(clngHKCU, strKey, 0, KEY_ALL_ACCESS, lngH)
    
  strX = vbNullString
  If (lngR = ERROR_NONE) Then
    'key opened successfully
    strX = String(1024, 0)
    lngX = Len(strX)
    ' Get key value
    lngR = RegQueryValueEx(lngH, strValue, 0, lngT, strX, lngX)
    If lngR = 0 Then
      ' Value returned
      If Asc(Mid(strX, lngX, 1)) = 0 Then lngX = lngX - 1
      strX = Left(strX, lngX)
    End If
  End If
  lngR = RegCloseKey(lngH)
  GetKeyValue = strX
End Function

And then call like this:

strResult = GetKeyValue("Software\Microsoft\Windows Messaging Subsystem\Profiles", "DefaultProfile")


Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
 
Yes, 'MS Exchange Settings' is quite normal. When Outlook is first run and the user opts for Corporate/Workgroup mode, a profile is configured and most Outlook versions use 'MS Exchange Settings' as the profile name. You wouldn't expect to see a user name. I've noticed that with OL2002 it now names the initial profile 'Outlook' so it's wise not to hard code and read it from the registry each time.

Paul Bent
Northwind IT Systems
 
Sorted!

When the user had the machine upgrade the default email software had been left as Outlook Express and not Outlook, this was then causing the problem with MAPI.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top