#include #include #include #include #include Opt('WinTitleMatchMode',2) Opt('SendKeyDelay',800) ;READS THUNDERBIRD EXPORTED CSV ADDRESS BOOK AND CREATES HTM FILE FOR WEB VIEWING ;When run is successful, your website will have an html file you can view with your smartphone (or other browser) ;It will be a list of your email contacts with their primary emall address. ;Clicking on the COPY button on each one will copy the respective email address to the clipboard. ;Then in your phone's email app, just paste the address in when you are sending a message. ;Clicking directly on the email address link will initiate a new email with your email client addressed to that party. ;WRITTEN BY WYSOCKI and posted to AUTOITSCRIPT.COM/FORUM - SEPTEMBER 2019 ;============================================================================= ;SET THESE VARIABLES FOR YOUR ENVIRONMENT: $tbexe = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe" ;Thunderbird executable $tempdir = "D:\temp\" ;path to a temporary folder $ftpServer = 'ftp.mydomain.com' ;webserver domain $ftpFolder = '/mydomain.com/' ;destination with leading and trailing slashes $ftpUsername = 'myuserid' ;user id for FTP login $ftpPass = 'mypassword' ;password for FTP login $fname = 'contact_email_list_' & @computername & '.html' ; name of destination html file to be uploaded to website ;============================================================================= if msgbox(4+32,'Export?','Export Thunderbird address book as a web page to '& $ftpServer &'?') = 6 Then ;EXPORT ADDRESS BOOK FROM THUNDERBIRD... $tb='Mozilla Thunderbird' if not WinExists($tb) Then run($tbexe) winwait($tb,'',5) EndIf WinActivate($tb) WinWaitActive($tb) send('!tb{tab}{tab}{down}!te') Opt('SendKeyDelay',100) send('{home}'& $tempdir &'{enter}') sleep(1000) winclose("Address Book") WinSetState($tb,'',@SW_MINIMIZE) ;READ ADDRESS BOOK INTO ARRAY... ; 0 1 2 3 4 5 $data = FileRead($tempdir & "Personal Address Book.csv") ;First Name,Last Name,Display Name,Nickname,Primary Email,Secondary Email $lineArr = StringSplit($data, @crlf,1) Local $arr[1][6] = [["First","Last","Display","Nick","Email1","Email2"]] $i = 2 while $i < $lineArr[0] ;build 2D array of contacts and sort $fld = stringsplit($lineArr[$i],',') if StringInStr($fld[5],'@') Then if $fld[3] == "" then $fld[3] = $fld[5] ;missing Display Name Local $new[1][6] = [[$fld[1],$fld[2],$fld[3],$fld[4],$fld[5],$fld[6]]] _ArrayAdd($arr,$new) endif $i = $i + 1 WEnd _ArraySort($arr,0,1,0,2) _ArrayDelete($arr,0) ;CREATE HTML FOR WEBPAGE AND SAVE TO DISK... $html = 'EMAIL CONTACTS' $html &='

Email Address Book:
(as of ' & _NowDate() & ')

' & @crlf for $i = 0 to ubound($arr)-1 if $arr[$i][4] > '' then $html &= '
' & $arr[$i][2] & '' $html &= '
 ' $html &= '' $html &= $arr[$i][4] & '

' & @crlf endif next $html &= '
' $html &='' $html &='' $html &= '' $file = FileOpen($tempdir & $fname,2) FileWrite($file,$html) FileClose($file) ;UPLOAD FILE TO WEBSERVER VIA FTP... Local $hOpen = _FTP_Open('MyFTP Control') Local $hConn = _FTP_Connect($hOpen, $ftpServer, $ftpUsername, $ftpPass) If @error Then MsgBox($MB_SYSTEMMODAL, '_FTP_Connect', 'UPLOAD ERROR=' & @error) Else _FTP_FilePut($hConn,$tempdir & $fname, $ftpFolder & $fname) msgbox(32,'FTP','FILE UPLOADED TO:'& @crlf & $ftpServer & ' as ' & $fname) EndIf Local $iFtpc = _FTP_Close($hConn) Local $iFtpo = _FTP_Close($hOpen) endif