Article View: cn.bbs.comp.program
Article #1328��MAPI�����ͺͻ�ȡ�����ʼ�
From: ���ܵ�Сʨ
Date: Sat, 18 Apr 1998 00:00
Date: Sat, 18 Apr 1998 00:00
149 lines
9992 bytes
9992 bytes
MS Visual FoxPro 3.0�ṩ���ʼ���Ӧ�ñ�̽ӿ�MAPI,��Window
s 95������ʹ��MAPI ���ƿ������ط��ͺͽ�����Ϣ,����ֻ������
Windows NT��Windows 95ʱ�Ű�װMAPI���ơ������û���ʹ�û�����
��Windows 3.2,��ʹ��MS Mail�����ʼ����ͺͽ�����Ϣ����������
����,�õ���MAPI����ķ���,��ʹVisual FoxPro 3.0������Ӧ����
�����е����ʼ����ܡ�
������Ļ�������������,����������һ�����ʹ��MAPI������
���պͷ��͵����ʼ�����Visual FoxPro 3.0�½���һ���µı?,��
�?���������ť,��������ť�ֱ���Ϊ���պͷ��͡�
�����հ�ť���Խ��շ���������Ը��ص��ʼ�;
�����Ͱ�ť���Է��������Ϣ;
����������ť���Է��������һ�?��,ִ��ʱֻ�谴�¸ð�ť
�Ϳ��Խ��պͷ�����Ϣ��
��MAPI��������ȡ�����ʼ�
��������д��������������ʼ�,��ô��Ӧ���ȵǼ�,���ʼ���
��ϵͳΪ�Լ�����һ���ʻ������������Լ�������ע��,ע�������
����MPLogon,�ڰ�ť��Click�¼���,д��:
session=10
a=mplogon(0,"UserName","Password",2,0,@session)
_screen.print(a)
�����Ļ��a�ķ���ֵΪ��,��ʾ������ȷ��ע�˲ᡣ
MPLogon�����еIJ���Flags��ֵ����������һ���µĻ�·�Ǽ�,
������һ���Ѿ����ڵĻ�·���Ǽǡ����仰˵,�����������Ӧ�ó�
��ʱ�ѵ�¼��Mail,����Flags����Ϊ1,��ô�㽫ʹ�ú�Mail��ͬ��ע
��;���Flags����Ϊ2,��ʾ��һ���µĻ�·ע�ᡣ
MPLogon�����е�UserName��Password����MAPI���û������
����,ͬ����WindowsĿ¼��������MSMAIL.INI��Ҳ��˶��塣ע����
ͨ����ͬ����������¼����ʱ�õ��û���������롣
��һ��Ҫ�����DZ�д�Ķ��ʹ�����Ϣ�Ĵ���,�������֪MAPI��
��ȥ"��ȡ"��Ϣ,�������ú���MPFindnextȥ����Ϣ�ı�ʶ��MPFindn
ext����һ���ض���·��IDֵ,Ϊ��һ�ε���MA PI�����ṩ��Ϣ��ʶ
�������MPFindnext�IJ���SeedMes-sageID��,����MPFindnext
���������ż��ĵ�һ����Ϣ��ʶ;�����Ϊ��,�ú����������
���ʼ���Ϣ��ʶ,ֱ������ֵΪ16,��ʾ�Ѿ����������е���Ϣ������
MPFindnext��������������յ����ʼ�,�������������յ����ʼ�,
�����ļ���������Ϣ,��ֻ����MPLogon��������Ч��·����Ч��
����Flags��ֵ�����˲����ʼ��ķ�ʽ�����Flags��ֵΪ256,��
���Ƚ��ȳ�(FIFO)��˳����Ϣ��ʶ��IDֵ,��Ȼ���ַ�ʽҪ����
��ʱ��;���Flags��ֵΪ32,��ֻ����δ���ʼ���IDֵ�����˸�IDֵ,
�Ϳ����ú���MPReadmail�����ʼ��ˡ�
���ú���MPReadmail����һ����Ϣ,����Ϣ���ʼ������⡢��
���ı��������˵�����͵�ַ�����������������ֵ���Ϣ,��������
����ʱ�ļ���Ŀ¼�С�����MPReadmail�IJ���Flags�����涨���ص�
���ߵ���Ϣ,�Ա���Visual FoxPro�����?���FlagsΪ64,�����߲�
�ú����������ʱ�ļ���,����Ҳ�������ʼ��ļ����ı��ļ�,��
�����ü����˺������ʱ��;���FlagsΪ2048,�ú���ؼ�����
���ļ����������Ϣ;���FlagsΪ512,���ú����ȫ������Ϣ����
��Ĺ�̰�����������ĵ��÷������ù����������UserName,��
��Passwordע��,��ȷע���,�ú���MPFindnext���ص�һ���ʼ���ID
ֵ,�ú���MPReadmail ��ȡ���ʼ�,����и���������·������
�ֱ�����Name1�С�
PROCEDURE Rcvmail
PARAMETER logonuser,password
set library to c:\vfp\tools\mapi\foxmapi
session=10
a=mplogon(0,UserName,password,1,0,@session)
if a��0
=messagebox("�����ʼ�ʧ��:��ע��",48,"�����ʼ�")
endif
declare arrayrecip(10),arrayfile(10)
arrayrecip(1)="myrecip"
arrayfile(1)="myfile"
=mpcursor("MapiMesg","mymesg")
=mpcursor("MapiRecip","myrecip")
=mpcursor("MapiRecip","myorig")
=mpcursor("mapifile","my-file")
id="
mesgid="
b=mpfindnext(1,0,",id,256,0,@MesgID)
id=MesgID
a=mpreadmail(1,0,ID,128,0,"mymesg",'myorig',arrayrecip,a
rrayfile)
sele myfile
if myfile.pathname��""
store myfile.pathname to name1
endif
a=mplogoff(session,0,0,0)
��MAPI���������͵����ʼ�
��������Ĺ�̿��Խ�������ʼ����͵���һ�ʾֵ���һ��
���С�������ʼ�һҪ,��Ҫ���Լ���UserName��Passwordע��,����
������·�����ļ����ռ��˵��ʾ�����������ռ��˵������
��д��MAPI Cursor��,Ȼ����ú���MpSendmail,���ɽ��ʼ����͵�
ָ������������С�
PROCEDURE Sendmail
PARAMETERS attachfile,recv-name,recvaddress
set default to c:\vfp\tools\mapi
set library to foxmapi
session=10
a=mplogon(-1,",",1,0,@session)
if a��0
=MessageBox("�ʼ�����ʧ��:��ע��",48,"����")
endif
=mpcursor
("MapiMesg","mymesg")
=mpcursor("MapiRecip","myrecip")
=mpcursor("MapiFile","my-file")
select mymesg
append blank
replace reserved with 0
replace subject with "CRE.R.DA-TA"
replace messagtype with "IPM.Microsoft.Note"
replace flags with 1
replace recipcount with 1
replace filecount with 1
sele myfile
append blank
replace reserved with 0
replace flags with 0
replace position with -1
replace pathname with attachfile
SELE MYRECIP
APPEND BLANK
replace RESERVED with 0
replace RECIPCLASS with 1
replace NAME with recvname
replace ADDRESS with recvaddress
a=mpsendmail(session,0,'mymesg','myrecip','myfile',1,0)
a=mplogoff(session,0,0,0)
if a=0
=MessageBox("�ʼ��ѳɹ�����!",64,"�����ʼ�")
return.T.
else
=MessageBox("�ʼ�����ʧ��:����ʱ����",48,"����")
return.F.
endif
����MAPI������
��һҪע�FOXMAPI�Ĵ���,��SET LIBRARY TO C:\VFP\TOOLS\
MAPI\FOXMAPI;
�ڶ��ڶ�MAPI����İ���ʱ,���˵ij�����Ƕ�ij���ֻ�ij�ַ�
������,��Ҫ�ڸò���ǰ�ӷ��@;
����Ҫ���MAPI Cursor�Ľṹ,MAPI Cursorʵ������MAPI����
����ʱ��ݿ�,���ڴ洢���ʼ��йصĸ�����Ϣ,��Mapi-File�洢��
����������Ϣ,MapiMesage�洢�ż�����Ϣ,Map iRecip�洢�ռ��˵�
��Ϣ���ڵ���MAPI�������ʼ�ʱ,ֻ����ȷ��д������Cursor,����
��ȷ�ص������ຯ��;
����Ҫ��ȷ���MAPI����ĸ������������,�纯��MPReadmail
�IJ���Re-cips()��Fil es()�ڵ���֮ǰ,Ҫ������Ϊ�����һ��Ԫ��
,�ڵ���ʱ���ܲ����?
����������Visual FoxPro 3.0������һ���?,�˱?������
��ť,������ť�������ǽ����ʼ��ͷ����ʼ�,����������ť��Click
�¼���,�ֱ���������Ĺ��Rcv-mail��Send mail,���������Ƶ�
��������ȷ�ؽ��ܺͷ��͵����ʼ��ˡ�
--
[m[1;37m�� ��Դ:���ϴ�С�ٺ���Ϣ����վ bbs.nju.edu.cn��[FROM: hsia.nju.edu.cn][m
Technical Details
Message-ID:
<3O9QV5$tT3@bbs.nju.edu.cn>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: Chinese,GB X-Google-Thread: fc86e,347e9abcd9fcc232,start X-Google-Attributes: gidfc86e,public From: pipishi.bbs@bbs.nju.edu.cn (���ܵ�Сʨ) Subject: ��MAPI�����ͺͻ�ȡ�����ʼ� Date: 1998/04/18 Message-ID: <3O9QV5$tT3@bbs.nju.edu.cn> X-Deja-AN: 345302916 X-Filename: Programming/M.892870613.A Organization: nju_bbs Newsgroups: cn.bbs.comp.program