Need MIME utility for email messages?
Keywords: MIME encode unencode decode
Question:
I am looking for DLL, EXE or whatever that does Mime conversion (at least decoding of messages and attached files) in batch mode, so that messages retrieved via POP calls (and sent via SMTP) may be handled correctly.I could write it myself, but it's probably a lot of work. What I'd like to do is retrieve a message into a local file, then call the utility and have it parse, decode and store the various message parts into separate files that can then be processed further.
Answer:
See the Postie extender for sending and receive POP3 in MIME format.
Option #1: Third Party Utility
I don't know if this ShareWare meets your needs, but take a look.I tried it to convert messages with attached files:
XFERPRO Version 1.1
Information Transfer Professional
Transfer Any Information Format, such as Video, Audio,Application Data or Image, via Internet Electronic Mail or InternetConnected Networks & On-Line Services
For Microsoft Windows,™ Windows for Workgroups 3.1/3.11,Windows 95 or Windows NT.
XFERPRO Copyright © 1994-6 by Sabasoft, Inc. All Rights Reserved. Sabasoft, Inc. 924 Bayhill Avenue Naperville, IL 60565 USAOr, point your browser to:http://members.aol.com/sabasoft http://www.sabasoft.comOption #2: Sample Code from One of Our Users:
Use any commercial mail reader such as Netscape, IE, or AGENT to send EMAIL message with one or more attached MIME files. Messages sent via mailing list, and files are ZIPPED at mail time. Zipped file content can be controlled by day of week and by customer mailing list. Source code with comments.;---------------------------------------------- ;MAIL.WBT ; Automated Mail Manager for Netscape ; Ver 1.0 3/17/98 ; 1.1 3/23/98 added Timer file on Mondays + holiday on Monday ; 1.2 4/30/98 added member list as param1 ; 1.3 5/4/98 send now instead of send later, 1 sec delays added ; to F)ile Ctl characters ; 1.4 5/8/98 Send new profile.cfg each day ; 1.5 5/15/98 Switch from Netscape to Agent ; 1.6 5/17/98 Process histories into cust zip files ; Process upgrades into cust zip files ; 1.7 6/1/98 Calculate time delay by file size ;------------------------------------------------------------------ AddExtender ("wwwsk34I.dll") DT = "%param2%" MAIL_DT=TimeYmdHms() ;DT="98:03:16:19:35:15" ; override processing date for testing ;SETUP ;---------------------------------------------- ONCANCEL="EXIT" gosub INIT_MAIL_TIME gosub INIT_FILE_DATE_TIME ; get yymmdd, hhmm, day + prev day from DT gosub INIT_FILES ; netscape, message, to_file, attach_file, @zip File gosub ASSIGN_NETSCAPE_VARIABLES ;======================================================================= ; MAIN PROGRAM ;======================================================================= ; testing ; --------- gosub start_agent boxopen("MAIL","Calling AT&T") gosub connect_line boxshut() winactivate("~Agent") MouseMove(500,700,"~Agent","") ;read mail list f_to=FileOpen (TO_file,"READ") while @true timedelay(1) member_info=FileRead(f_to) if member_info == "*EOF*" then break col_1=StrSub(member_info,1,1) if StrCmp(col_1,":") == 0 timedelay(1) continue endif if StrCmp(col_1,";") == 0 timedelay(1) continue endif gosub make_message endwhile FileClose(f_to) ;end mailing list ;exit_mail ;----------- sendkey("!F") timedelay(1) sendkey("X") nRet = DUNDisconnect (hConn) exit ;======================================================================= ; ROUTINES ;======================================================================= ;--------------------- :start_agent ;--------------------- dirchange ("C:\program files\agent") run(Agent,"") dirchange("D:\MAIL") timedelay(3); return ;--------------------- :connect_line ;--------------------- gosub connect_att bytes=0 while 1 timedelay(4) td=wxGetInfo(3,hConn) if td == bytes then break bytes = td endwhile return ;================================================================== :make_message ;================================================================== member_count=member_count+1 first_name=StrCat(ItemExtract(1,member_info,","),",") timedelay(1) winactivate("~Agent") email_address=ItemExtract(2,member_info,",") timedelay(1) password=ItemExtract(3,member_info,",") hist_file = StrCat("D:\MAIL\",password,".HST") timedelay(1) Stk_yn=ItemExtract(4,member_info,",") MF_yn=ItemExtract(5,member_info,",") Fut_yn=ItemExtract(6,member_info,",") Tmr_yn=ItemExtract(7,member_info,",") file_profile=StrCat(stk_yn,mf_yn,fut_yn,tmr_yn) if (StrCmp(StrUpper(file_profile),"NNNY") == 0 ) ;Send Stock/Timer only timedelay(4) if (StrCmp(day,"Sun") == 0) then goto msg_continue if (StrCmp(day,"Mon") == 0) then return if (StrCmp(day,"Tue") == 0) then return if (StrCmp(day,"Wed") == 0) then return if (StrCmp(day,"Thu") == 0) then return if (StrCmp(day,"Fri") == 0) then return endif if (StrCmp(StrUpper(tmr_yn),"N") == 0) if(StrCmp(day,"Sun") == 0) then return endif :msg_continue if (StrCmp(holiday_today,"YES") == 0) timedelay(4) if (StrCmp(day,"Mon") == 0) then return if (StrCmp(day,"Tue") == 0) then return if (StrCmp(day,"Wed") == 0) then return if (StrCmp(day,"Thu") == 0) then return if (StrCmp(day,"Fri") == 0) then return ;don't send any files on holidays no exceptions endif ;NEW_MESSAGE sendkey("!P") timedelay(1) sendkey("E") timedelay(1) WinWaitExist("~[No Subject]",5) sendkey("!T") ;To sendkey(email_address) timedelay(1) sendkey("!B") ;suBject timedelay(1); subject=StrCat("PISCES FILE FOR ",YYMMDD) sendkey(subject) timedelay(1); sendkey("!X") ;teXt timedelay(1); gosub get_message ; enters message text timedelay(1) gosub MAKE_ZIPS ; uses variables password,stk_yn,fut_yn,mf_yn timedelay(1) ;CALCULATE SEND DELAY ;--------------------- ; attach_file now includes all histories, updates, etc fsize=FileSize(attach_file_name) send_delay = int (fsize/bytes_per_sec) if send_delay < 40 then send_delay=send_delay+5 winactivate("~Agent") ;ATTACH_FILE ;--------------------- sendkey("!A") ; Attach timedelay(1) sendkey("!A") ; Add timedelay(1) sendkey(Attach_file_name) ; specify attach file name-path timedelay(2) sendkey("!O") ;Open timedelay(1) sendkey(enter) timedelay(1) ;SEND_MAIL_NOW sendkey("!M") ;Message timedelay(1) sendkey("N") ;send Now :data_sent xmt_sec=0 boxopen( strcat(email_address," TIME_DELAY=",send_delay," LETTER COUNT=",member_count),xmt_sec) while 1 timedelay(1) xmt=wxGetInfo(3,hConn) rcv=wxGetInfo(4,hConn) xmt_sec = xmt_sec+1 boxtext(strcat("SECONDS=",xmt_sec," XMIT=",xmt," RCV=",rcv) ) if xmt_sec >= send_delay then break endwhile boxshut() winactivate("~Agent") return ;========================================================================= ; END OF SEND MESSAGE ;========================================================================= ;---------------------- :cancel ;--------------------- %oncancel% exit :redial timedelay(30) ;--------------------- :connect_ATT ;----------------------- sTitle = "INTERNET" hConn = 0 sdial="WorldNet" hConn = DUNConnect (sDial) nErr = wxGetLastErr() if (!hConn) select (nErr) case @SErrBusy Message (sTitle,"Couldn't connect to %sDial%: Line busy.") break case @SErrNoAnswer Message (sTitle,"Couldn't connect to %sDial%: No answer.") break case @SErrVoice Message (sTitle,"Couldn't connect to %sDial%: A human answered.") break case nErr display (5,sTitle,"Couldn't connect to %sDial%: Error %nErr%.") break end select goto redial else boxopen (sTitle,"Connected to %sDial%.%@CRLF%Connect handle = %hConn%, error %nErr%.") timedelay(5) boxshut() endif return ;--------------------------- :get_message ;--------------------------- gosub init_mail_time timedelay(1) sendkey(first_name) timedelay(1) sendkey(enter) msg="Here is your " if (StrCmp(StrUpper(tmr_yn),"Y") == 0 ) if (StrCmp(day,"Sun") == 0) then msg=StrCat(msg,"Timer/Newsletter-") endif if (StrCmp(day,"Sun") == 0) then goto msg_sunday if (StrCmp(holiday_today,"NO") == 0) if (StrCmp(StrUpper(stk_yn),"Y") == 0) then msg=StrCat(msg,"Stocks-") if (StrCmp(StrUpper(fut_yn),"Y") == 0 ) then msg=StrCat(msg,"Futures-") if (StrCmp(StrUpper(mf_yn),"Y") == 0 ) then msg=StrCat(msg,"Funds-") if FileExist(hist_file) == 1 then msg=StrCat(msg,"Histories-") endif :msg_sunday msg=StrCat(msg," File... Sent ",MAIL_DAY,", ",MAIL_HHMM) sendkey(msg) sendkey(enter) if (StrCmp(holiday_today,"YES") == 0) if (StrCmp(StrUpper(tmr_yn),"Y") == 0 ) if (StrCmp(day,"Mon") == 0) then sendkey("*** HAPPY HOLIDAY ***") if (StrCmp(day,"Mon") == 0) then sendkey(enter) endif endif msg=FileOpen (message_file,"READ") while @true m=FileRead(msg) if m == "*EOF*" then break sendkey(m) sendkey(enter) endwhile FileClose(msg) return ;---------------------------- :init_mail_time ;---------------------------- MAIL_DT=TimeYmdHms() MAIL_HHMM=StrSub(MAIL_DT,10,5) MAIL_YYMMDD=StrCat(StrSub(DT,1,2),StrSub(DT,4,2),StrSub(DT,7,2)) J=TimeJulianDay(MAIL_DT) c=(J+5) mod 7 MAIL_DAY=ItemExtract(c+1, "Sun Mon Tue Wed Thu Fri Sat"," ") return ;---------------------------- :init_file_date_time ;---------------------------- HHMM=StrSub(DT,10,5) DTm1=DT YYMMDD=StrCat(StrSub(DT,1,2),StrSub(DT,4,2),StrSub(DT,7,2)) MATCH=" " holiday_today = "NO" WHILE @true ; get prev market day, skip over wkends, holidays DTm1=TimeSubtract(DTm1,"00:00:01:00:00:00") YYMMDDm1=StrCat(StrSub(DTm1,1,2),StrSub(DTm1,4,2),StrSub(DTm1,7,2)) MMDDYYm1=StrCat(StrSub(DTm1,4,2),"/",StrSub(DTm1,7,2),"/",StrSub(DTm1,1,2)) MMDDYY=StrCat(StrSub(DT,4,2),"/",StrSub(DT,7,2),"/",StrSub(DT,1,2)) J=TimeJulianDay(DTm1) c=(J+5) mod 7 DAY=ItemExtract(c+1, "Sun Mon Tue Wed Thu Fri Sat"," ") if StrCmp(day,"Sat") == 0 then continue if StrCmp(day,"Sun") == 0 then continue h=FileOpen ("C:\HOLIDAYS.TXT","READ") while @true MMDDYY_H=FileRead(h) if MMDDYY_H == "*EOF*" then break if StrCmp(MMDDYY_H,MMDDYYm1) == 0 then match=mmddyy_h if StrCmp(MMDDYY_H,MMDDYY) == 0 then holiday_today = "YES" endwhile FileClose(h) if StrCmp(MMDDYYm1,match) == 0 then continue break endwhile J=TimeJulianDay(DT) c=(J+5) mod 7 DAY=ItemExtract(c+1, "Sun Mon Tue Wed Thu Fri Sat"," ") return ;------------------------------ :init_files ;------------------------------ netscape = "C:\program files\netscape\communicator\program\netscape.exe" agent = "C:\program files\agent\agent.exe" message_file = "D:\MAIL\MESSAGE.TXT" ;contains message text to_file = "%param1%" zip_file_name = strcat("D:\MAIL\PK",YYMMDD,".ZIP") ; PK980312.ZIP attach_file_name = strcat("D:\MAIL\PK",YYMMDD,".EXE") ; PK980312.EXE profile_file_name="D:\MAIL\PROFILE.CFG" fut_path = StrCat(Environment("FUT"),"\MAXX\FU") stk_path = StrCat(Environment("STAGING"),"\MAX-ST\ST") mf_path = StrCat(Environment ("MF"),"\MAX\MF") stk_file = StrCat(stk_path,YYMMDD,".PRN") fut_file = StrCat(fut_path,YYMMDD,".PRN") fut_filem1 = StrCat(fut_path,YYMMDDm1,".PRN") mf_file = StrCat(mf_path,YYMMDD,".PRN") mf_filem1 = StrCat(mf_path,YYMMDDm1,".PRN") holiday_file="C:\HOLIDAYS.TXT" zip_list_file = "D:\MAIL\ZIPFILES.LST" timer_file = "C:\TIMER\STKDATA.EXE" items_file = "C:\PACKIT\MASTER.PAK" pkzip = "C:\U\PKZIP.EXE" zip2exe = "C:\U\ZIP2EXE.EXE" return ;------------------------------ :assign_netscape_variables ;------------------------------ mail="-MAIL" get_messages="!FTN" enter="~" tab="{TAB}" send_mail_later="!FL" send_unsent="!FM" member_count=0 send_delay= 0 fsize=0 bytes_per_sec=1800 return ;----------------------------------------------------------------- :sendstr ;----------------------------------------------------------------- ;parce string into characters with 1 sec delay x=0; timedelay(1) while x < 100 x=x+1 a=strsub(str,x,1) sendkey(a) timedelay(1) if x== strlen(str) then break endwhile return ;----------------------------------------------------------------- :make_zips ;uses variables password,stk_yn,fut_yn,mf_yn,tmr_yn ;----------------------------------------------------------------- ;zip parms if FileExist(attach_file_name) == 1 then FileDelete(attach_file_name) if FileExist(zip_file_name) == 1 then FileDelete(zip_file_name) if FileExist(profile_file_name) == 1 then FileDelete(profile_file_name) parm=StrCat("-S",password,"MAIL"," -O ") ;passwd + overwrite ;Create Profile File fp=FileOpen(profile_file_name,"WRITE") FileWrite(fp,member_info) FileClose(fp) ;Create Zip control file fw=FileOpen(zip_list_file,"WRITE") FileWrite(fw,StrCat(":MAIL ZIP FILE CONTROL ",YYMMDD," TIME ",HHMM) ) FileWrite(fw,":====================================================") FileWrite(fw,profile_file_name) zips=StrCat(parm,zip_file_name," @",zip_list_file) if(StrCmp(day,"Sun") == 0) then goto file_continue if (StrCmp(holiday_today,"NO") == 0) if (StrCmp(StrUpper(stk_yn),"Y") == 0) then FileWrite(fw,stk_file) if (StrCmp(StrUpper(fut_yn),"Y") == 0 ) then FileWrite(fw,fut_filem1) if (StrCmp(StrUpper(fut_yn),"Y") == 0 ) then FileWrite(fw,fut_file) if (StrCmp(StrUpper(mf_yn),"Y") == 0 ) then FileWrite(fw,mf_filem1) if (StrCmp(StrUpper(mf_yn),"Y") == 0 ) then FileWrite(fw,mf_file) if (StrCmp(day,"Fri") == 0) then FileWrite(fw,items_file) endif if (StrCmp(holiday_today,"YES") == 0) then FileWrite(fw,holiday_file) :file_continue if (StrCmp(StrUpper(tmr_yn),"Y") == 0) if(StrCmp(day,"Sun") == 0) then FileWrite(fw,timer_file) endif gosub process_histories gosub process_upgrades FileClose(fw) ;Make Zip file boxopen("MAIL","Zip Files") runwait ("c:\u\pkzip.exe",zips) boxtext("Zip2Exe Files") runwait("c:\u\zip2exe.exe",zip_file_name) boxshut() return :process_histories ;--------------------------- if FileExist(hist_file) == 1 hist_path = "d:\hist-all\" hst=FileOpen (hist_file,"READ") while @true h=FileRead(hst) if h == "END_LIST" then break item=strcat(hist_path,h) ; if FileExist(item) == 1 then message("History File",item) if FileExist(item) == 1 then FileWrite(fw,item) endwhile FileClose(hst) filedelete(hist_file) endif return :process_upgrades ;----------------- upgrade_file = "d:\mail\upgrade.txt" if FileExist(upgrade_file) == 1 upg=FileOpen (upgrade_file,"READ") while @true u=FileRead(upg) if u == "*EOF*" then break ; if FileExist(u) == 1 then message("UPGRADE FILE",u) if FileExist(u) == 1 then FileWrite(fw,u) endwhile FileClose(upg) endif return
Article ID: W13171Filename: MIME Utility for Email Messages.txt