Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
techwiki:dos [2019/11/22 00:05]
ying [basic operation]
techwiki:dos [2020/02/27 19:37] (current)
ying [start a process]
Line 136: Line 136:
  
  
 +**Outlook**
  
 +  * create a email with content python version (the main code block) <code python>
 +# rough support code for reference
 +config['​appPath'​]['​email'​] = [r'​C:​\Program Files\Microsoft Office\Office*\OUTLOOK.EXE'​]
 +
 +# main code
 +app = self.getOptionPath(config['​appPath'​],​ '​email'​) # the outlook app path
 +address_list = ['​test@test.com'​]
 +subject = 'Daily Feedback'​
 +text_list = ['line 1', 'line 2']
 +cmd = '"​{0}"​ /c ipm.note /m "​{1}&​subject={2}&​body={3}"'​.format(app,​ ';'​.join(address_list),​ subject, '​\n'​.join(text_list))
 +if os.path.isfile(app):​
 +    print(cmd)
 +    subprocess.Popen(cmd)
 +
 +# support function for reference
 +    def getOptionPath(self,​ dict, name, all=0):
 +        # updated: 2019.01.09
 +        if name not in dict.keys():​
 +            print('​Dict has no key: {0}'​.format(name))
 +            return
 +        option_list = []
 +        if not isinstance(dict[name],​ (list,​tuple)):​
 +            option_list = [ dict[name] ]
 +        else:
 +            option_list = dict[name]
 +        if all == 0:
 +            found = None
 +            for option in option_list:​
 +                if '​*'​ in option:
 +                    # wildchar search
 +                    import glob
 +                    sub_option_list = glob.glob(option)
 +                    if len(sub_option_list) > 0:
 +                        sorted_option_list = sorted(sub_option_list)
 +                        print('​Scaning options:​\n'​+'​\n'​.join(sorted_option_list))
 +                        found = sorted_option_list[-1]
 +                        break
 +                else:
 +                    if os.path.exists(option):​
 +                        found = option
 +                        break
 +            if found is not None:
 +                found = found.replace('​\\','/'​)
 +            print('​found:​ {0}'​.format(found))
 +            return found
 +        else:
 +            all_option = []
 +            for option in option_list:​
 +                if '​*'​ in option:
 +                    # wildchar search
 +                    import glob
 +                    sub_option_list = glob.glob(option)
 +                    all_option.extend(sorted(sub_option_list,​ reverse=1))
 +                else:
 +                    if os.path.exists(option):​
 +                        all_option.append(option)
 +            standard_path_option = []
 +            for each_path in all_option:
 +                standard_path = each_path.replace('​\\','/'​)
 +                if standard_path not in standard_path_option:​
 +                    standard_path_option.append(standard_path)
 +            print(standard_path_option)
 +            return standard_path_option
 +</​code>​
 +  * outlook attach file (/c imp.note need or not need?) <code dos>​outlook.exe /c ipm.note /a "​FileAttachPathName"​ /m "​email@addresses.com&​cc=&​subject=&​body="</​code>​
 +    * ref: https://​www.slipstick.com/​outlook/​how-to-use-outlooks-command-line-switches/​
 ===== system operation ===== ===== system operation =====