A MAPI example for Microsoft Mail (Functions/Subroutines/Programs)

This is an example of how to send a MAPI mail message using Microsoft Mail. The most common error is omitting the value for the POS_TYPE$ field, which for Microsoft Mail, is "IPM.Microsoft Mail.Note".

declare subroutine Msg, Get_Status

declare function MapiSendMail

$insert Mapi_Equates

equ CRLF$ to \0D0A\

equ CR$ to \0D\

equ LF$ to \0A\

equ TAB$ to \09\

* this example of sending a mail message is called from

* a form that contains the following controls:

* - TextMessage edit box

* - CompanyName edit line

* - CompanyAddress edit line

* - Region edit line

* - OrderData edit table

* - Subject edit line

* - To edit line

Txt = .TextMessage→Text : CRLF$

Txt := "Company: ": .CompanyName→Text : CRLF$

Txt := "Address: ": .CompanyAddress→Text: CRLF$

Txt := "Region : ": .Region→Text : CRLF$

Orders = .OrderData→List

convert @fm:@vm to LF$:TAB$ in Orders

Txt := Orders

Flags = MAPI_LOGON_UI$ + MAPI_DIALOG$

Message = ''

Message<POS_SUBJECT$> = .Subject→Text

Message<POS_TO$ > = .To→Text

Message<POS_TEXT$ > = Txt

Message<POS_FLAGS$ > = MAPI_RECEIPT_REQUESTED$

Message<POS_TYPE$ > = "IPM.Microsoft Mail.Note"

if MAPISendMail(0, 0, Flags, Message) then

Msg(@window, "Message sent successfully!")

end else

Get_Status(ErrMsg)

Msg(@window, ErrMsg)

end

return 0

________

See also: MAPISendMail, MAPI_Equates insert record

Source code:

charset_utf-8

Contributed by John Van Buren/Revelation

  • kb/kb_articles/kb0014.txt
  • Last modified: 2024/01/30 13:36
  • by 127.0.0.1