source: GuiMail/trunk/p/CWMAILB.m@ 1505

Last change on this file since 1505 was 1139, checked in by George Lilly, 14 years ago

version 2.3 of GuiMail

File size: 5.0 KB
Line 
1CWMAILB ;INDPLS/PLS- DELPHI VISTA MAIL SERVER CON'T ;21-Jun-2005 06:34;CLC
2 ;;2.3;CWMAIL;;Jul 19, 2005
3 ; modified 10/8/1999 to fix problem with reply text tab conversion
4%FORWARD(CWDATA,CWINPUT,CWTEXT) ;
5 ;Input: 1st Piece of CWINPUT holds IEN of Message
6 ; CWTEXT holds recipient list
7 ;
8 N XMZ,XMY,CWLP,CWSDATA,CWSEDATA,CWTMP,CWFILE,CWIEN,CWNAM,XMINSTR,CWMSG
9 N XMKZA
10 S XMZ=$P(CWINPUT,";")
11 S CWDATA(1)="0^^AN ERROR HAS OCCURRED"
12 G:'$G(XMZ) FOREND
13 S CWSDATA=$G(CWTEXT(-9902),"[START DATA]"),CWSEDATA=$G(CWTEXT(-9903),"[END DATA]")
14 S CWLP=-1 D FNDLP(.CWLP,CWSDATA)
15 G:$G(CWLP)="" FOREND
16 F S CWLP=$O(CWTEXT(CWLP)) Q:CWLP="" Q:CWTEXT(CWLP)=CWSEDATA D
17 .S CWTMP=$G(CWTEXT(CWLP)) Q:CWTMP=""
18 .S CWFILE=+$P(CWTMP,"^"),CWIEN=+$P(CWTMP,"^",2),CWNAM=$P(CWTMP,"^",3)
19 .I CWFILE=200 S XMY(CWIEN)=""
20 .E I CWFILE=3.8 S XMY("G."_CWNAM)=""
21 .E S XMY(CWNAM)=""
22 I $D(XMY) D
23 . S XMKZA(XMZ)=""
24 . D FWDMSG^XMXAPI(XMDUZ,"",.XMKZA,.XMY,.XMINSTR,.CWMSG)
25 ;RETURNS <number of messages> forwarded.
26 S CWDATA(1)=+CWMSG_U_U_XMZ ;FORCE TO SUCCESS
27FOREND Q
28 ;
29%TERMIN(CWDATA,CWINPUT) ;TERMINATE A MESSAGE THREAD
30 ;Input: 1st piece = IEN of Message
31 ; 2nd piece = IEN of Mail Basket
32 ;
33 N XMRC,XMZ,XMK,Y,CWMSGNM,CWMSGR
34 S CWDATA(1)="0^^AN ERROR HAS OCCURRED"
35 S XMZ=$P($G(CWINPUT),";"),XMK=$P($G(CWINPUT),";",2)
36 S CWMSGNM(XMZ)=""
37 D TERMMSG^XMXAPI(XMDUZ,"",.CWMSGNM,.CWMSGR)
38 ;RETURNS <number of messages> terminated.
39 S CWDATA(1)=+CWMSGR_U_U ;return 1 for success or 0
40 Q
41FNDLP(CWLP,X) ;FIND A CHARACTER STRING ENTRY
42 F S CWLP=$O(CWTEXT(CWLP)) Q:CWLP="" Q:CWTEXT(CWLP)=X
43 Q
44 ;
45INCNT(CWCNT) ;INCREMENT COUNTER
46 Q CWCNT+1
47 ;
48%CREATE(DATA,INPUT,TEXT) ;CREATE A NEW MESSAGE
49 ;BUILD RETURN CODES FOR ERROR MESSAGING
50 D %CREATE^CWMAIL2
51 Q
52 ;
53%REPLY(CWDATA,CWINPUT,CWTEXT) ; This API uses global array for text
54 ;INPUT - Piece 1 : Message Number
55 ; Piece 2-4 : Not Used
56 ; Piece 5 : Network Reply Flag (0 = no; 1 = yes)
57 ;
58 N CWMSGN,CWRESULT,CWSDATA,CWSEDATA,CWTMP,CWNWCHK,CWDATT
59 N CWMSGT,XMZR,CWLP,XMINSTR
60 S CWMSGN=$P(CWINPUT,";")
61 S CWNWCHK=$P(CWINPUT,";",5)
62 S CWDATA(1)="0^UNDEFINED ERROR"
63 S CWTEXT=$NA(^TMP($J,"CWMAILLOAD"))
64 G:'$G(CWMSGN) REPEND
65 S CWSDATA=$G(@CWTEXT@(-9900),"[START DATA]"),CWSEDATA=$G(@CWTEXT@(-9901),"[END DATA]")
66 S CWLP=-1 D GFNDLP(.CWLP,CWSDATA)
67 G:$G(CWLP)="" REPEND
68 F S CWLP=$O(@CWTEXT@(CWLP)) Q:CWLP="" Q:@CWTEXT@(CWLP)=CWSEDATA D
69 .S ^TMP($J,"CWMAILOUT",CWLP)=$G(@CWTEXT@(CWLP))
70 G:'$D(^TMP($J,"CWMAILOUT")) REPEND
71 S CWMSGT=$NA(^TMP($J,"CWMAILOUT"))
72 D CNVTAB^CWMAIL2(CWMSGT) ;convert tabs to spaces
73 S XMINSTR("NET REPLY")=$S(+$G(CWNWCHK):1,1:0)
74 D REPLYMSG^XMXAPI(XMDUZ,"",CWMSGN,CWMSGT,.XMINSTR,.XMZR)
75 I +$G(XMZR)>0 S CWDATA(1)=$S(CWNWCHK:2,1:1)_"^NO ERRORS"_U_CWMSGN ;SUCCESS
76 E S CWDATA(1)="0^"_$G(CWDATA)_U_CWMSGN ;RETURN ERROR MESSAGE
77REPEND K ^TMP($J,"CWMAILLOAD"),^TMP($J,"CWMAILOUT")
78 Q
79GFNDLP(CWLP,X) ;FIND A CHARACTER STRING ENTRY IN GLOBAL
80 F S CWLP=$O(@CWTEXT@(CWLP)) Q:CWLP="" Q:@CWTEXT@(CWLP)=X
81 Q
82 ;
83%ANSWER(CWDATA,CWINPUT,CWTEXT) ; This API uses global array for text to answer a message
84 ;INPUT - CWINPUT : Piece 1 : Message Number
85 ; Piece 2 : Not Used
86 ; Piece 3 : Message Attributes
87 ; Pieces 4-5 : Not Used
88 ; CWTEXT : Holds list of additional recipients
89 ;
90 N CWSDATA,CWSEDATA,CWLP,CWTXTARY,DA,DIE,DR,Y,XMTEXT
91 N CWMSGABS,CWTMP,CWFILE,CWIEN,CWNAM
92 N XMBODY,CWMSGN,XMY,XMZ,XMINSTR
93 S CWMSGN=$P(CWINPUT,";") ;MESSAGE NUMBER
94 I $G(CWMSGN)<1 S CWDATA(1)="0^98- No message number given" G ANSEND
95 S CWDATA(1)="0^99- UNDEFINED ERROR"
96 ;TEXT ARRAY CONTAINS RECIPIENT LIST AND MESSAGE TEXT LOADED FROM BMSGD call
97 ;BUILD XMY ARRAY
98 S CWTEXT=$NA(^TMP($J,"CWMAILLOAD"))
99 S CWSDATA=$G(@CWTEXT@(-9902),"[START XMY]"),CWSEDATA=$G(@CWTEXT@(-9903),"[END XMY]")
100 S CWLP=-1 D GFNDLP^CWMAILB(.CWLP,CWSDATA)
101 ;RETRIEVE RECIPIENTS
102 I $G(CWLP)'="" D
103 . F S CWLP=$O(@CWTEXT@(CWLP)) Q:CWLP="" Q:@CWTEXT@(CWLP)=CWSEDATA D
104 . . S CWTMP=$G(@CWTEXT@(CWLP)) Q:CWTMP=""
105 . . S CWFILE=+$P(CWTMP,"^"),CWIEN=+$P(CWTMP,"^",2),CWNAM=$P(CWTMP,"^",3)
106 . . I CWFILE=200 S XMY(CWIEN)=""
107 . . E I CWFILE=3.8 S XMY("G."_CWNAM)=""
108 . . E S XMY(CWNAM)="" ;treat address as internet address
109 ;BUILD MESSAGE @TEXT@ ARRAY
110 S CWSDATA=$G(@CWTEXT@(-9900),"[START DATA]"),CWSEDATA=$G(@CWTEXT@(-9901),"[END DATA]")
111 S CWLP=-1 D GFNDLP^CWMAILB(.CWLP,CWSDATA)
112 I $G(CWLP)="" S CWDATA(1)="0^3- NO MESSAGE TEXT" G ANSEND
113 F S CWLP=$O(@CWTEXT@(CWLP)) Q:CWLP="" Q:@CWTEXT@(CWLP)=CWSEDATA D
114 .S ^TMP($J,"CWMAILOUT",CWLP)=$G(@CWTEXT@(CWLP))
115 ;I '$D(^TMP($J,"CWMAILOUT")) S CWDATA(1)="0^3- NO MESSAGE TEXT" G ANSEND ;NO MESSAGE @CWTEXT@
116 ;I '$L($P($G(CWINPUT),";")) S CWDATA(1)="0^4- MESSAGE SUBJECT NOT GIVEN" G ANSEND
117 ;E S XMSUBJ=$P($G(CWINPUT),";")
118 ;PROCESS MESSAGE
119 S XMBODY=$NA(^TMP($J,"CWMAILOUT"))
120 S XMINSTR("FLAGS")=$P(CWINPUT,";",3) ;GET MESSAGE ATTRIBUTES
121 D ANSRMSG^XMXAPI(XMDUZ,"",CWMSGN,"",XMBODY,.XMY,.XMINSTR,.XMZ)
122 I $G(XMZ)<1 S CWDATA(1)="0^5- MESSAGE ANSWER FAILED" G ANSEND
123 I +$G(XMZ)>0 S CWDATA(1)="1^^"_$G(XMZ)
124ANSEND K ^TMP($J,"CWMAILOUT"),^TMP($J,"CWMAILLOAD")
125 Q
Note: See TracBrowser for help on using the repository browser.