-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshu-mail.wbt
58 lines (52 loc) · 2.12 KB
/
shu-mail.wbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
AddExtender("wwwsk32i.dll")
AddExtender("wsrch32i.dll")
LclDir=IniReadPvt("Local", "Directory", "c:\import\", "movemail.ini")
LclExtn=IniReadPvt("Local", "Extentions", "*.mai", "movemail.ini")
LclArch=IniReadPvt("Local", "ArchDir", "c:\archive\br_mail\", "movemail.ini")
MailSvr=IniReadPvt("Server", "Mailsvr", "mail.hannahs", "movemail.ini")
FromDomain=IniReadPvt("Server", "FromDomain", "hannahs.co.nz", "movemail.ini")
ToDomain=IniReadPvt("Server", "ToDomain", "hannahs.co.nz", "movemail.ini")
dasubj = "Branch Mail"
count=0
SrchHandle = SrchInit(LclDir, LclExtn, "", "", 16 )
SrchFile=srchNext(SrchHandle)
while SrchFile != ""
frombr=itemextract(3,SrchFile,"\")
ArchFile = StrReplace(SrchFile,LclDir,"")
ArchFile = StrCat(LclArch,StrReplace(ArchFile,"\",""))
If !FileAppend( SrchFile, ArchFile) then
dasubj = "Branch Mail processsing failure"
damsg = "Processing failed on %whofrom% %whoto% in %SrchFile%"
whofrom = "[email protected]"
whoto = "[email protected]"
rc = smtpSendText (mailsvr, whofrom, whoto, dasubj, damsg)
display(15,"ERROR","Failed to write to the combined file")
Exit
End If
whofrom = strcat(frombr,"@",FromDomain)
whotoshort = fileroot(SrchFile)
whoto = strcat(whotoshort,"@",ToDomain)
; message(whofrom,whoto)
rc = smtpSendFile (MailSvr, whofrom, whoto, dasubj, SrchFile)
if !rc then
dasubj = "Branch Mail processsing failure"
damsg = "Processing failed on %whofrom% %whoto% in %SrchFile%"
whofrom = "[email protected]"
whoto = "[email protected]"
rc = smtpSendText (mailsvr, whofrom, whoto, dasubj, damsg)
display(15,"Emailing the file from %frombr% in couldn't be sent","")
exit
endif
count = count +1
timedelay(5)
DeleteFile=SrchFile
SrchFile=srchNext(SrchHandle)
FileDelete(DeleteFile)
endwhile
srchFree(SrchHandle)
dasubj = "Branch Mail processsing success"
damsg = "Processed %count% messages"
whofrom = "[email protected]"
whoto = "[email protected]"
rc = smtpSendText (mailsvr, whofrom, whoto, dasubj, damsg)
display(30,"Completed ","%count% messages")