Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MAPISendMessage

Posted on 1998-10-19
15
Medium Priority
?
285 Views
Last Modified: 2008-03-10
I'm trying to use the MAPISendMessage function to send a plain text message.
However, I only got the function, the constants and some arguments. I don't know how to use them.

I'd like to have an example. Most important: I don't want any control to be involved. Just call a MAPI function to send a text-string message. Can anyone please help me?
If worth the answer I will increase the points, of course.
0
Comment
Question by:kulikuli
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 3
15 Comments
 
LVL 1

Accepted Solution

by:
Geffl earned 50 total points
ID: 1440546
Create a new module and paste the following code in it:

Public Declare Function MAPILogon Lib "MAPI32.DLL" (ByVal UIParam&, ByVal User$, ByVal Password$, ByVal Flags&, ByVal Reserved&, Session&) As Long
Public Declare Function MAPISendMail Lib "MAPI32.DLL" Alias "BMAPISendMail" (ByVal Session&, ByVal UIParam&, Message As MAPIMessage, Recipient() As MapiRecip, File() As MapiFile, ByVal Flags&, ByVal Reserved&) As Long
Public Declare Function MAPILogoff Lib "MAPI32.DLL" (ByVal Session&, ByVal UIParam&, ByVal Flags&, ByVal Reserved&) As Long
Public Declare Function MAPIResolveName Lib "MAPI32.DLL" Alias "BMAPIResolveName" (ByVal Session&, ByVal UIParam&, ByVal UserName$, ByVal Flags&, ByVal Reserved&, Recipient As MapiRecip) As Long
Public Declare Function MAPIFindNext Lib "MAPI32.DLL" Alias "BMAPIFindNext" (ByVal Session&, ByVal UIParam&, MsgType$, SeedMsgID$, ByVal Flag&, ByVal Reserved&, MsgID$) As Long



Global MAPISess As Long
Global MAPISessOK As Boolean

Public Const MAPI_DIALOG = &H8
Public Const MAPI_NEW_SESSION = &H2
Public Const MAPI_LOGON_UI = &H1
Public Const MAPI_UNREAD_ONLY = &H20
Public Const MAPI_E_NO_MESSAGES = 16

Public Type MapiFile
    Reserved As Long
    Flags As Long
    Position As Long
    PathName As String
    FileName As String
    FileType As String
End Type

Public Type MAPIMessage
    Reserved As Long
    Subject As String
    NoteText As String
    MessageType As String
    DateReceived As String
    ConversationID As String
    Flags As Long
    RecipCount As Long
    FileCount As Long
End Type

Public Type MapiRecip
    Reserved As Long
    RecipClass As Long
    Name As String
    Address As String
    EIDSize As Long
    EntryID As String
End Type

Public Function OpenSession()
    Call MAPIModule.MAPILogon(0, "<ProfileName>", "", MAPI_LOGON_UI, 0, MAPISess)
    If MAPISess > 0 Then
        MAPISessOK = True
    Else
        MAPISessOK = False
    End If
End Function
Public Function SendMail(Text$)
    If MAPISessOK = True Then
        Dim MAPIEmpf(0) As MapiRecip
        Dim MAPIDatei(0) As MapiFile
        Dim MAPINachricht As MAPIMessage

        MAPINachricht.Subject = "<Subject of text>"
        MAPINachricht.NoteText = "<Text>"
               
        Call MAPIModule.MAPIResolveName(MAPISess, 0, "<To>", MAPI_DIALOG, 0, MAPIEmpf(0))
        MAPINachricht.RecipCount = 1
        Call MAPIModule.MAPISendMail(MAPISess, 0, MAPINachricht, MAPIEmpf, MAPIDatei, 0, 0)
    End If
End Function
Public Function CloseSession()
    If MAPISessOK = True Then
        ret& = MAPIModule.MAPILogoff(MAPISess, 0, 0, 0)
    End If
End Function

Use these functions:
    MAPIModule.OpenSession
    MAPIModule.SendMail ("Text")
    MAPIModule.CloseSession
In MapiModule.OpenSession you have to correct the profile name which is stored locally on your workstation.
I hope this can help you and I´ve tested it only with Exchange 5 and Winnt WS 4 SP3 ...

kind regards
0
 
LVL 5

Author Comment

by:kulikuli
ID: 1440547
Geffl, Thank you very much!!! I've been searching for weeks for something like this! I'll get back to you as soon as I got the results from my implementing it. Just to let you know: I'm using Pegasus Mail for Win32.
0
 
LVL 5

Author Comment

by:kulikuli
ID: 1440548
What I in fact really am trying to do is send an email without even using a mailapplication like Pegasus or Outlook. Is this not possible at all???
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:Geffl
ID: 1440549
In such a case you should try to use a command-line SMTP mail program (such as blat). This solution has a lot advantages:
You need no client application installed, because the mapi.dll will be installed with the client.
You can attach files easily.
There´s no dependency on the client application. I don´t know which differences the mapi.dll of Pegasus has compared with Outlook. If you can´t find blat.exe, post it here and I´ll help!
0
 
LVL 5

Author Comment

by:kulikuli
ID: 1440550
I've been looking for Blat and I found it. It seems to have some nice capabilities for use in scripts for example. However, my objective is to have an email sent by my application. I won't bother about including another dll to call some functions on, but Blat seems to edit the registry. This is something I'd like to avoid. But I'd like to thank you once more for pointing it out to me. Since the sourcecode is all availlable I might try to rewrite Blat to my own specifications. I guess, without a program like Blat or mailapplication there is no possibility to email? There is no standard functionality in Windows avaliable? Like some Telnet dll or whatever?
0
 
LVL 1

Expert Comment

by:Geffl
ID: 1440551
No. There are no standard-functions in Windows, because each e-mail client provides a different API with different functions. So the best way for you to be independent, is using standard SMTP communication. You can program your own functions (Winsocket connection, open port 25, ...) or you can use already written utilities ...
0
 
LVL 5

Author Comment

by:kulikuli
ID: 1440552
Thank you very much for all your comments. I am really learning (and losing some illusions) on how to provide email capabilities. I'll get back to you after testing your function.
Best regards,

kulikuli
0
 
LVL 5

Author Comment

by:kulikuli
ID: 1440553
I am experiencing a problem when testing your code. I suspect it has to be something to do with the profile. I use windows 95 and I don't know what profile I have to give in. This is probably causing MS Access to crash, because each time I run the procedure it crashes....
0
 
LVL 1

Expert Comment

by:Geffl
ID: 1440554
Which e-mail client do you use now?
0
 
LVL 5

Expert Comment

by:chewhoung
ID: 1440555
If you're using Exchange, go to control panel->Mail->Show Profile->Add to add a new profile.
0
 
LVL 5

Expert Comment

by:chewhoung
ID: 1440556
If you're using Exchange, go to control panel->Mail->Show Profile->Add to add a new profile.
0
 
LVL 5

Expert Comment

by:chewhoung
ID: 1440557
Sorry For Reposting.
0
 
LVL 5

Author Comment

by:kulikuli
ID: 1440558
I'm still using Pegasus.
0
 
LVL 1

Expert Comment

by:Geffl
ID: 1440559
I´m sorry, but I think, that my sample code won´t work with pegasus!
0
 
LVL 5

Author Comment

by:kulikuli
ID: 1440560
Well, I guess I have to post this question once more...
However, I feel I have to reward you for your efforts and for the hint on Blat and inspiration... so thank you very much for that.
Best regards,

kulikuli
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question