home *** CD-ROM | disk | FTP | other *** search
/ Galleria D'arte: Manet / Manet.iso / Dati / Gadgets.dxr / Internal_96_GetUserEmailPref().ls < prev    next >
Encoding:
Text File  |  2000-12-21  |  9.3 KB  |  287 lines

  1. global EmailPref
  2.  
  3. on GetUserEmailPref InfoToLocate
  4.   if (InfoToLocate > 2) or (InfoToLocate < 1) then
  5.     return EMPTY
  6.     exit
  7.   end if
  8.   try = 1
  9.   if voidp(EmailPref) then
  10.     EmailPref = [EMPTY, EMPTY]
  11.   else
  12.     return getAt(EmailPref, InfoToLocate)
  13.   end if
  14.   default = dosReadReg("HKEY_LOCAL_MACHINE", "Software\Clients\Mail", EMPTY)
  15.   if default contains "Outlook Express" then
  16.     Priority = [0, 1, 2, 3, 4, 5, 6, 7, 10]
  17.   else
  18.     if default contains "Outlook" then
  19.       Priority = [1, 0, 2, 3, 4, 5, 6, 7, 10]
  20.     else
  21.       if default contains "Netscape" then
  22.         Priority = [2, 3, 0, 1, 4, 5, 6, 7, 10]
  23.       else
  24.         if default contains "Eudora" then
  25.           Priority = [5, 0, 1, 2, 3, 4, 6, 7, 10]
  26.         else
  27.           if default contains "Pegasus" then
  28.             Priority = [6, 0, 1, 2, 3, 4, 5, 7, 10]
  29.           else
  30.             if default contains "Becky" then
  31.               Priority = [7, 0, 1, 2, 3, 4, 5, 6, 10]
  32.             else
  33.               Priority = [0, 1, 2, 3, 4, 5, 6, 7, 10]
  34.             end if
  35.           end if
  36.         end if
  37.       end if
  38.     end if
  39.   end if
  40.   repeat while getAt(EmailPref, InfoToLocate) = EMPTY
  41.     case getAt(Priority, try) of
  42.       0:
  43.         EmailPref = CheckOutlook(1)
  44.       1:
  45.         EmailPref = CheckOutlook(2)
  46.       2:
  47.         EmailPref = CheckNetscape(4)
  48.       3:
  49.         EmailPref = CheckNetscape(3)
  50.       4:
  51.         EmailPref = CheckInternetMail()
  52.       5:
  53.         EmailPref = CheckEudoraLight()
  54.       6:
  55.         EmailPref = CheckPegasus()
  56.       7:
  57.         EmailPref = CheckBecky()
  58.       10:
  59.         exit repeat
  60.       otherwise:
  61.     end case
  62.     try = try + 1
  63.   end repeat
  64.   return getAt(EmailPref, InfoToLocate)
  65. end
  66.  
  67. on CheckNetscape Ver
  68.   Pref = [EMPTY, EMPTY]
  69.   if Ver = 3 then
  70.     email = dosReadReg("HKEY_CURRENT_USER", "Software\Netscape\Netscape Navigator\User", "User_Addr")
  71.     name = dosReadReg("HKEY_CURRENT_USER", "Software\Netscape\Netscape Navigator\User", "User_Name")
  72.     smtp = dosReadReg("HKEY_CURRENT_USER", "Software\Netscape\Netscape Navigator\Services", "SMTP_Server")
  73.     if email <> EMPTY then
  74.       if name <> EMPTY then
  75.         setAt(Pref, 1, name & " <" & email & ">")
  76.       else
  77.         setAt(Pref, 1, email)
  78.       end if
  79.     end if
  80.     if smtp <> EMPTY then
  81.       setAt(Pref, 2, smtp)
  82.     end if
  83.   else
  84.     if Ver = 4 then
  85.       name = EMPTY
  86.       email = EMPTY
  87.       smtp = EMPTY
  88.       the itemDelimiter = "\"
  89.       NetscapePath = dosReadReg("HKEY_CURRENT_USER", "Software\Netscape\Netscape Navigator\Main", "Install Directory")
  90.       CurrentUser = dosReadReg("HKEY_CURRENT_USER", "Software\Netscape\Netscape Navigator\biff", "CurrentUser")
  91.       if (NetscapePath <> EMPTY) and (CurrentUser <> EMPTY) then
  92.         delete char -30002 of NetscapePath
  93.         if dosIsFileExist(NetscapePath & "\Users\" & CurrentUser & "\prefs.js") then
  94.           PrefFile = new(xtra("FileIO"))
  95.           openFile(PrefFile, NetscapePath & "\Users\" & CurrentUser & "\prefs.js", 1)
  96.           if status(PrefFile) = 0 then
  97.             fLine = readLine(PrefFile)
  98.             the itemDelimiter = QUOTE
  99.             repeat while fLine <> EMPTY
  100.               if fLine contains "mail.identity.username" then
  101.                 name = item 4 of fLine
  102.               else
  103.                 if fLine contains "mail.identity.useremail" then
  104.                   email = item 4 of fLine
  105.                 else
  106.                   if fLine contains "network.hosts.smtp_server" then
  107.                     smtp = item 4 of fLine
  108.                   end if
  109.                 end if
  110.               end if
  111.               fLine = readLine(PrefFile)
  112.             end repeat
  113.           end if
  114.           closeFile(PrefFile)
  115.           PrefFile = 0
  116.           if email <> EMPTY then
  117.             email = " <" & email & ">"
  118.           end if
  119.           Pref = [name & email, smtp]
  120.         end if
  121.       end if
  122.     end if
  123.   end if
  124.   return Pref
  125. end
  126.  
  127. on CheckInternetMail
  128.   Pref = [EMPTY, EMPTY]
  129.   email = dosReadReg("HKEY_CURRENT_USER", "Software\Microsoft\Internet Mail and News\Mail", "Sender Email")
  130.   name = dosReadReg("HKEY_CURRENT_USER", "Software\Microsoft\Internet Mail and News\Mail", "Sender Name")
  131.   smtp = dosReadReg("HKEY_CURRENT_USER", "Software\Microsoft\Internet Mail and News\Mail", "Default SMTP Server")
  132.   if email <> EMPTY then
  133.     if name <> EMPTY then
  134.       setAt(Pref, 1, name & " <" & email & ">")
  135.     else
  136.       setAt(Pref, 1, email)
  137.     end if
  138.   end if
  139.   if smtp <> EMPTY then
  140.     setAt(Pref, 2, smtp)
  141.   end if
  142.   return Pref
  143. end
  144.  
  145. on CheckOutlook Ver
  146.   Pref = [EMPTY, EMPTY]
  147.   if Ver = 1 then
  148.     Account = dosReadReg("HKEY_CURRENT_USER", "Software\Microsoft\Internet Account Manager", "Default Mail Account")
  149.     email = dosReadReg("HKEY_CURRENT_USER", "Software\Microsoft\Internet Account Manager\Accounts\" & Account, "SMTP Email Address")
  150.     name = dosReadReg("HKEY_CURRENT_USER", "Software\Microsoft\Internet Account Manager\Accounts\" & Account, "SMTP Display Name")
  151.     smtp = dosReadReg("HKEY_CURRENT_USER", "Software\Microsoft\Internet Account Manager\Accounts\" & Account, "SMTP Server")
  152.   else
  153.     if Ver = 2 then
  154.       Account = dosReadReg("HKEY_CURRENT_USER", "Software\Microsoft\Office\8.0\Outlook\OMI Account Manager", "Default Mail Account")
  155.       email = dosReadReg("HKEY_CURRENT_USER", "Software\Microsoft\Office\8.0\Outlook\OMI Account Manager\Accounts\" & Account, "SMTP Email Address")
  156.       name = dosReadReg("HKEY_CURRENT_USER", "Software\Microsoft\Office\8.0\Outlook\OMI Account Manager\Accounts\" & Account, "SMTP Display Name")
  157.       smtp = dosReadReg("HKEY_CURRENT_USER", "Software\Microsoft\Office\8.0\Outlook\OMI Account Manager\Accounts\" & Account, "SMTP Server")
  158.     end if
  159.   end if
  160.   if email <> EMPTY then
  161.     if name <> EMPTY then
  162.       setAt(Pref, 1, name & " <" & email & ">")
  163.     else
  164.       setAt(Pref, 1, email)
  165.     end if
  166.   end if
  167.   if smtp <> EMPTY then
  168.     setAt(Pref, 2, smtp)
  169.   end if
  170.   return Pref
  171. end
  172.  
  173. on CheckEudoraLight
  174.   Pref = [EMPTY, EMPTY]
  175.   EudoraPath = dosReadReg("HKEY_CURRENT_USER", "Software\Qualcomm\Eudora\CommandLine", "Current")
  176.   if EudoraPath = EMPTY then
  177.     return Pref
  178.     exit
  179.   end if
  180.   EudoraPath = word 1 of EudoraPath
  181.   the itemDelimiter = "\"
  182.   delete char -30002 of EudoraPath
  183.   EudoraINI = EudoraPath & "\Eudora.ini"
  184.   name = dosReadINI(EudoraINI, "Settings", "RealName")
  185.   email = dosReadINI(EudoraINI, "Settings", "ReturnAddress")
  186.   smtp = dosReadINI(EudoraINI, "Settings", "SMTPServer")
  187.   if email <> EMPTY then
  188.     if name <> EMPTY then
  189.       setAt(Pref, 1, name & " <" & email & ">")
  190.     else
  191.       setAt(Pref, 1, email)
  192.     end if
  193.   end if
  194.   if smtp <> EMPTY then
  195.     setAt(Pref, 2, smtp)
  196.   end if
  197.   return Pref
  198. end
  199.  
  200. on CheckPegasus
  201.   Pref = [EMPTY, EMPTY]
  202.   MailBoxPath = dosReadReg("HKEY_CURRENT_USER", "Software\Pegasus Mail\Mailbox", EMPTY)
  203.   if MailBoxPath = EMPTY then
  204.     MailBoxPath = dosReadReg("HKEY_CURRENT_USER", "Software\Pegasus Mail\BaseDir", EMPTY)
  205.     if MailBoxPath = EMPTY then
  206.       return Pref
  207.       exit
  208.     else
  209.       CFGFile = new(xtra("FileIO"))
  210.       openFile(CFGFile, MailBoxPath & "\Pmail.cfg", 1)
  211.       if status(CFGFile) <> 0 then
  212.         return Pref
  213.         exit
  214.       end if
  215.       MailBoxPath = readLine(CFGFile)
  216.       repeat with i = 1 to the number of chars in MailBoxPath
  217.         if charToNum(char i of MailBoxPath) = 0 then
  218.           MailBoxPath = char 1 to i - 1 of MailBoxPath
  219.         end if
  220.       end repeat
  221.       closeFile(CFGFile)
  222.       CFGFile = 0
  223.       if dosIsFileExist(MailBoxPath & "\Pmail.ini") then
  224.         the itemDelimiter = "\"
  225.         delete char -30002 of MailBoxPath
  226.         CFGFile = new(xtra("FileIO"))
  227.         openFile(CFGFile, MailBoxPath & "\Pmail.usr", 1)
  228.         if status(CFGFile) <> 0 then
  229.           return Pref
  230.           exit
  231.         end if
  232.         the itemDelimiter = ";"
  233.         fLine = " "
  234.         repeat while fLine <> EMPTY
  235.           fLine = readLine(CFGFile)
  236.           if char 1 of fLine = numToChar(10) then
  237.             delete char 1 of fLine
  238.           end if
  239.           if item 1 of fLine = "A" then
  240.             MailBoxPath = MailBoxPath & "\" & item 2 of fLine
  241.             exit repeat
  242.           end if
  243.         end repeat
  244.         closeFile(CFGFile)
  245.         CFGFile = 0
  246.       end if
  247.     end if
  248.   end if
  249.   MailBoxINI = MailBoxPath & "\Pmail.ini"
  250.   name = dosReadINI(MailBoxINI, "General", "Personal name")
  251.   email = dosReadINI(MailBoxINI, "Pegasus Mail for Windows - built-in TCP/IP Mail", "Alternative From: field for message")
  252.   if email = EMPTY then
  253.     email = dosReadINI(MailBoxINI, "General", "Default reply-to address")
  254.   end if
  255.   smtp = dosReadINI(MailBoxINI, "Pegasus Mail for Windows - built-in TCP/IP Mail", "SMTP relay host for outgoing mail")
  256.   if email <> EMPTY then
  257.     if name <> EMPTY then
  258.       setAt(Pref, 1, name & " <" & email & ">")
  259.     else
  260.       setAt(Pref, 1, email)
  261.     end if
  262.   end if
  263.   if smtp <> EMPTY then
  264.     setAt(Pref, 2, smtp)
  265.   end if
  266.   return Pref
  267. end
  268.  
  269. on CheckBecky
  270.   Pref = [EMPTY, EMPTY]
  271.   Account = dosReadReg("HKEY_CURRENT_USER", "Software\RIMArts\Rebecca\Settings", "DefUser")
  272.   email = dosReadReg("HKEY_CURRENT_USER", "Software\RIMArts\Rebecca\Users\" & Account, "Address")
  273.   name = dosReadReg("HKEY_CURRENT_USER", "Software\RIMArts\Rebecca\Users\" & Account, "Name")
  274.   smtp = dosReadReg("HKEY_CURRENT_USER", "Software\RIMArts\Rebecca\Users\" & Account, "SMTP")
  275.   if email <> EMPTY then
  276.     if name <> EMPTY then
  277.       setAt(Pref, 1, name & " <" & email & ">")
  278.     else
  279.       setAt(Pref, 1, email)
  280.     end if
  281.   end if
  282.   if smtp <> EMPTY then
  283.     setAt(Pref, 2, smtp)
  284.   end if
  285.   return Pref
  286. end
  287.