Windows 7 - Live Mail - smapi.dll - Windows 7

Asked By rick allison on 03-Jun-10 09:12 PM
I am an MS Access developer.
I have use VBA code to access Windows Live Mail.
In Vista the smapi.dll file worked for me.

In Windows 7 the smapi.dll file no longer works for me.

Does anyone know if there is a difference between the smapi.dll files from
Vista to Windows 7?

More specifically, in Vista smapi.dll is located here: c:\program
files\windows live\mail\smapi.dll
In Windows 7 smapi.dll is located here: c:\program files (x86)\windows
live\mail\smapi.dll

In my VBA code I have the following...
'Declarations below:
'**************************
'   CONSTANT Declarations
'**************************
'


Global Const SUCCESS_SUCCESS = 0
Global Const MAPI_USER_ABORT = 1
Global Const MAPI_E_FAILURE = 2
Global Const MAPI_E_LOGIN_FAILURE = 3
Global Const MAPI_E_DISK_FULL = 4
Global Const MAPI_E_INSUFFICIENT_MEMORY = 5
Global Const MAPI_E_BLK_TOO_SMALL = 6
Global Const MAPI_E_TOO_MANY_SESSIONS = 8
Global Const MAPI_E_TOO_MANY_FILES = 9
Global Const MAPI_E_TOO_MANY_RECIPIENTS = 10
Global Const MAPI_E_ATTACHMENT_NOT_FOUND = 11
Global Const MAPI_E_ATTACHMENT_OPEN_FAILURE = 12
Global Const MAPI_E_ATTACHMENT_WRITE_FAILURE = 13
Global Const MAPI_E_UNKNOWN_RECIPIENT = 14
Global Const MAPI_E_BAD_RECIPTYPE = 15
Global Const MAPI_E_NO_MESSAGES = 16
Global Const MAPI_E_INVALID_MESSAGE = 17
Global Const MAPI_E_TEXT_TOO_LARGE = 18
Global Const MAPI_E_INVALID_SESSION = 19
Global Const MAPI_E_TYPE_NOT_SUPPORTED = 20
Global Const MAPI_E_AMBIGUOUS_RECIPIENT = 21
Global Const MAPI_E_MESSAGE_IN_USE = 22
Global Const MAPI_E_NETWORK_FAILURE = 23
Global Const MAPI_E_INVALID_EDITFIELDS = 24
Global Const MAPI_E_INVALID_RECIPS = 25
Global Const MAPI_E_NOT_SUPPORTED = 26


Global Const MAPI_E_NO_LIBRARY = 999
Global Const MAPI_E_INVALID_PARAMETER = 998


Global Const MAPI_ORIG = 0
Global Const MAPI_TO = 1
Global Const MAPI_CC = 2
Global Const MAPI_BCC = 3


Global Const MAPI_UNREAD = 1
Global Const MAPI_RECEIPT_REQUESTED = 2
Global Const MAPI_SENT = 4


'***********************
'   FLAG Declarations
'***********************


Global Const MAPI_LOGON_UI = &H1
Global Const MAPI_NEW_SESSION = &H2
Global Const MAPI_DIALOG = &H8
Global Const MAPI_UNREAD_ONLY = &H20
Global Const MAPI_ENVELOPE_ONLY = &H40
Global Const MAPI_PEEK = &H80
Global Const MAPI_GUARANTEE_FIFO = &H100
Global Const MAPI_BODY_AS_FILE = &H200
Global Const MAPI_AB_NOMODIFY = &H400
Global Const MAPI_SUPPRESS_ATTACH = &H800
Global Const MAPI_FORCE_DOWNLOAD = &H1000


Global Const MAPI_OLE = &H1
Global Const MAPI_OLE_STATIC = &H2


Type MAPIRecip
Reserved As Long
RecipClass As Long
Name As String
Address As String
EIDSize As Long
EntryID As Long 'Originally String
End Type


Type MAPIFileTag    'Not used at all now
Reserved As Long
TagLength As Long




...winston replied to rick allison on 03-Jun-10 10:42 PM
The API for WLM has not been made public..I do not recall any information available that would answer your question.

--
...winston
ms-mvp mail
Geoff Clark \(MSFT\) replied to ...winston on 04-Jun-10 07:36 AM
Why use the WLM version of that file directly? If you use the system's
mapi32.dll it will use the default mail client on the machine.

-geoff


The API for WLM has not been made public..I do not recall any information
available that would answer your question.

--
...winston
ms-mvp mail
Michael Santovec replied to rick allison on 04-Jun-10 05:12 PM
The difference in file locations is because you are running a 32 bit
version of Vista and a 64 bit version of Win7.

On a 64 bit version of Windows, 32 bit applications get installed to
c:\program files (x86)

--

Mike - http://TechHelp.Santovec.us
rick allison replied to ...winston on 07-Jun-10 12:15 PM
Oh no, no API.

I took the code I had for Outlook Express and used it.  I had to remove the
file attachment variable to make it work.
rick allison replied to Geoff Clark \(MSFT\) on 07-Jun-10 12:17 PM
I want to force the use of WLM and not make the user have to use WLM as
their default mail system.  Many of my customers want to use Outlook as
their default mail system and I cannot programmatically turn off the warning
message about sending email from another program.  As far as I know, this
warning message cannot be turned of from Outlook like it can from WLM.

Rick
rick allison replied to Michael Santovec on 16-Jun-10 09:53 AM
Update on what has happened.

I created another module in Access (WLM32in64) because I have to hard code
the folder in the function
Declare Function MAPISendMail Lib "c:\program files (x86)\windows
live\mail\smapi.dll" ( _
ByVal Session As Long, _
ByVal UIParam As Long, _
Message As MAPIMessage, _
ByVal Flags As Long, _
ByVal Reserved As Long) As Long

When I did this it works.

What I have learned...
1) the function must be called MAPISendMail.
2) in Windows 7 the first and second attempt to send an email fail, the
third attempt succeeds.  This happens only on the first attempt to send an
email with windows live mail and the MAPISendMail function.  I have no idea
why.
Code to make sending mail work for the very first email sent.
MAPISendMail
If MAPIError then
MAPISendMail
if MAPIError then
MAPISendMail - the email is sent on the third attempt.
end if
end if

What's strange is this, in Vista MAPISendMail has to try twice  and in
Windows XP it works every time on the first attempt.
Remember, this is for the very first email being sent from MS Access upon
opening of the MS Access program.  Once the first email attempt is complete,
every email after that works on the first attempt.  No need to try two or
three times.  That's just plain weird to me.  But heck it works.

I hope this helps someone else.

If there is a better way to do this, I am very interested.

Rick
C C replied to rick allison on 20-Apr-11 09:51 AM
according to this article

http://msdn.microsoft.com/en-us/library/dd296721%28v=vs.85%29.aspx

Windows Live Mail as of Sept 09, does not support MAPISendmail