Results 1 to 5 of 5

Thread: REGWRITE to add new outlook express account

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2001
    Posts
    1,384

    REGWRITE to add new outlook express account

    I need code that will add a new account in Outlook Express. I want to the user to enter their username; displayname and pop3 password. I have code that will add the username and displayname:
    Code:
    set oShell = wscript.CreateObject("Wscript.Shell")
    
    Function main()
    dim username, domain, displayname
    
    username = inputbox("Enter your USERNAME (Do not include @.xx at the end)","Email Setup")
    
    If username = "" Then
    wscript.Quit(0)
    End If
    
    If username = "Username" Then
    while username = "Enter your Email PREFIX or USERNAME"
    username = inputbox("Enter your Email PREFIX or username (before the @ sign)","Outlook Express Profile Creator","Username")
    If username = "" Then
    wscript.Quit(0)
    End If
    wend
    End If
    
    displayname = inputbox("Enter your DISPLAY NAME (The name you want people to see when you E-Mail them","Internet Email Setup")
    
    If displayname = "" Then
    wscript.Quit(0)
    End If
    
    domain = "test.com"
    
    ' displayname = Ltrim(fixme(displayname))
    ' username = Ltrim(fixme(username))
    ' domain = fixme2(domain)
    
    'EXAMPLE STRING FOR RTRIM
    ' RTrim(string)
    
    call placeMailSettings(username, displayname, domain)
    
    msgbox("Outlook Express Configuration Complete, please start Outlook Express and enter your password when prompted.")
    End Function
    
    Function regRead(regStr)
    regRead = oShell.RegRead(regStr)
    End Function
    
    Function regWrite(val1,val2,val3)
    oShell.RegWrite val1,val2,val3
    End Function
    
    Function regDelete(regStr)
    call oShell.RegDelete(regStr)
    End Function
    
    Function placeMailSettings(theUsername, thedisplayname, theDomain)
    On Error Resume Next
    dim newAccountNum, numKeyStr
    dim username, displayname, domain, msvcmail
    msvcMail="1.255.4.12"
    newAccountNum = regRead("HKCU\Software\Microsoft\Internet Account Manager\Account Name")
    
    If newAccountNum = "" Then
    newAccountNum = "00000001"
    ElseIf newAccountNum < 9 Then
    newAccountNum = "0000000" & newAccountNum
    Else
    newAccountNum = "000000" & newAccountNum 
    End If
    
    numKeyStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\"
    call regWrite(numKeyStr, newAccountNum, "REG_SZ")
    
    username = theUsername
    displayname = thedisplayname
    domain = theDomain
    
    'Add Account Name
    accName = username & "@" & domain
    accNameStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\Account Name"
    call regWrite(accNameStr, accName, "REG_SZ")
    
    'Add Connection Type
    conType = "3"
    conTypeStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\Connection Type"
    call regWrite(conTypeStr, conType, "REG_DWORD")
    
    'Delete Connection Id
    conId = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\ConnectionId"
    call regDelete(conId)
    
    'Delete Account Id
    accId = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\Account ID"
    call regDelete(accId)
    
    'Delete IMAP Server
    imapSvr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\IMAP Server"
    call regDelete(imapSvr)
    
    'Delete HTTP Mail Server
    httpSvr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\HTTPMail Server"
    call regDelete(httpSvr)
    
    'Set POP3 Server
    pop3svr = msvcMail
    pop3svrStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\POP3 Server"
    call regWrite(pop3svrStr, pop3svr, "REG_SZ")
    
    'Set POP3 Username
    pop3usr = username
    pop3usrStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\POP3 User Name"
    call regWrite(pop3usrStr, pop3usr, "REG_SZ")
    
    'Delete POP3 Password 2
    popPwdStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\POP3 Password2"
    call regDelete(popPwdStr)
    
    'Set POP3 Use Sicily
    useSicily = "0"
    useSicilyStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\POP3 Use Sicily"
    call regWrite(useSicilyStr, useSicily, "REG_DWORD")
    
    'Set POP3 Prompt for Pw
    var promptPw = "1"
    var promptPwStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\POP3 Prompt for Password"
    call regWrite(promptPwStr, promptPw, "REG_DWORD")
    
    'Set SMTP Server
    smtpSvr = msvcMail
    smtpSvrStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\SMTP Server"
    call regWrite(smtpSvrStr, smtpSvr, "REG_SZ")
    
    'Set SMTP Display name
    smtpDisp = displayname
    smtpSvrStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\SMTP Display Name"
    call regWrite(smtpSvrStr, smtpDisp, "REG_SZ")
    
    'Set SMTP E-mail address
    smtpEmail = username & "@" & domain
    smtpEmailStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\SMTP Email Address"
    call regWrite(smtpEmailStr, smtpEmail, "REG_SZ")
    
    'Set SMTP Use Sicily
    smtpUseSicily = "2"
    smtpUseSicilyStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\SMTP Use Sicily"
    call regWrite(smtpUseSicilyStr, smtpUseSicily, "REG_DWORD")
    
    'Set New Account to default
    defAccStr = "HKCU\Software\Microsoft\Internet Account Manager\Default Mail Account"
    call regWrite(defAccStr, newAccountNum, "REG_SZ")
    
    'Increment future account number
    futAccNum = newAccountNum + 1
    futAccNumStr = "HKCU\Software\Microsoft\Internet Account Manager\Account Name"
    call regWrite(futAccNumStr, futAccNum, "REG_DWORD")
    
    msgbox("POP3 Server Set to: " & pop3svr & chr(10) & "SMTP Server Set to: " & smtpSvr)
    End Function
    
    call main()
    But this doesn't allow me to assign the pop3 password, how can I do this? The trouble is that that passwords are stored as binary values. I'd appreciate any help.
    Mel

  2. #2
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: REGWRITE to add new outlook express account

    writing a binary string is easy enough, but not with WSH. For that you need the APIs, WMI, or you could conceivably create .reg files and do it with regedit. Aren't the passwords encrypted anyway ?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2001
    Posts
    1,384

    Re: REGWRITE to add new outlook express account

    Any suggestion on how to do it???
    Mel

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: REGWRITE to add new outlook express account

    The passwords will be encrypted. Without knowing the exact alogorithum you wont be able to duplicate it. Why do you need to create the account programmatically?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2001
    Posts
    1,384

    Re: REGWRITE to add new outlook express account

    Basically I have a customer who has a load of sites. They want to automatically set up outlook express accounts for the sites without having to have someone manually set them up. My code reads in the username displayname, password (blank), domainname and POP3 location from a CVS file and creates the account in outlook express.
    Code:
    set oShell = wscript.CreateObject("Wscript.Shell")
    
    Function main()
    
    	ReadFile
    
    End Function
    
    Sub ReadFile()
    
    	' Read in account details from .csv file
    	Set objFSO = CreateObject("Scripting.FileSystemObject")
    	Set objFile = objFSO.OpenTextFile("C:\Dermot\10AccountDetails.csv", 1)
    
    	Do Until objFile.AtEndOfStream
         		Redim Preserve arrFileLines(i)
    	     	arrFileLines(i) = objFile.ReadLine
    
         		Aryrecord = Split(arrFileLines(i), ",")
    		ReDim Preserve UserName(i), DisplayName(i), Pwd(i), DomainName(i), POP3Location(i)
    
                	UserName(y) = AryRecord(0)
                	DisplayName(y) = AryRecord(1)
                	Pwd(y) = AryRecord(2)
                	DomainName(y) = AryRecord(3)
    		POP3Location(y) = AryRecord(4)
    
    		call placeMailSettings(UserName(y), DisplayName(y), Pwd(y), DomainName(y),POP3Location(y))
    	     	
    		msgbox UserName(y) & " set up"
    		i = i + 1
    		y = y + 1
    	Loop
    	
    	objFile.Close
    	
    	msgbox "Finished Reading File"
    
    End Sub
    
    
    Function placeMailSettings(theUsername, thedisplayname, thePWD, theDomain, thePOP3)
    On Error Resume Next
    dim newAccountNum, numKeyStr
    dim username, displayname, domain, pop3 'msvcmail
    
    	'Set new account to user name
    	newAccountNum = regRead("HKCU\Software\Microsoft\Internet Account Manager\Account Name")
    
    	' Find next available account number
    	If newAccountNum = "" Then
    		newAccountNum = "00000001"
    	ElseIf newAccountNum < 9 Then
    		newAccountNum = "0000000" & newAccountNum
    	Else
    		newAccountNum = "000000" & newAccountNum 
    	End If
    
    	' Add account number
    	numKeyStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\"
    	call regWrite(numKeyStr, newAccountNum, "REG_SZ")
    
    	username = theUsername
    	displayname = thedisplayname
    	domain = theDomain
    	pop3 = thePOP3
    
    	'Add Account Name
    	accName = username & "@" & domain
    	accNameStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\Account Name"
    	call regWrite(accNameStr, accName, "REG_SZ")
    
    	'Add Connection Type
    	conType = "3"
    	conTypeStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\Connection Type"
    	call regWrite(conTypeStr, conType, "REG_DWORD")
    
    	'Set POP3 Server
    	pop3svr = pop3
    	pop3svrStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\POP3 Server"
    	call regWrite(pop3svrStr, pop3svr, "REG_SZ")
    
    	'Set POP3 Username
    	pop3usr = username
    	pop3usrStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\POP3 User Name"
    	call regWrite(pop3usrStr, pop3usr, "REG_SZ")
    
    	'Set POP3 Use Sicily
    	useSicily = "0"
    	useSicilyStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\POP3 Use Sicily"
    	call regWrite(useSicilyStr, useSicily, "REG_DWORD")
    
    	'Set POP3 Prompt for Pw
    	promptPw = "1"
    	promptPwStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\POP3 Prompt for Password"
    	call regWrite(promptPwStr, promptPw, "REG_DWORD")
    
    	'Set SMTP Server
    	smtpSvr = pop3
    	smtpSvrStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\SMTP Server"
    	call regWrite(smtpSvrStr, smtpSvr, "REG_SZ")
    
    	'Set SMTP Display name
    	smtpDisp = displayname
    	smtpSvrStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\SMTP Display Name"
    	call regWrite(smtpSvrStr, smtpDisp, "REG_SZ")
    
    	'Set SMTP E-mail address
    	smtpEmail = username & "@" & domain
    	smtpEmailStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\SMTP Email Address"
    	call regWrite(smtpEmailStr, smtpEmail, "REG_SZ")
    
    	'Set SMTP Use Sicily
    	smtpUseSicily = "2"
    	smtpUseSicilyStr = "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\SMTP Use Sicily"
    	call regWrite(smtpUseSicilyStr, smtpUseSicily, "REG_DWORD")
    
    	'Set New Account to default
    	defAccStr = "HKCU\Software\Microsoft\Internet Account Manager\Default Mail Account"
    	call regWrite(defAccStr, newAccountNum, "REG_SZ")
    
    	'Increment future account number
    	futAccNum = newAccountNum + 1
    	futAccNumStr = "HKCU\Software\Microsoft\Internet Account Manager\Account Name"
    	call regWrite(futAccNumStr, futAccNum, "REG_DWORD")
    
    	'msgbox("POP3 Server Set to: " & pop3svr & chr(10) & "SMTP Server Set to: " & smtpSvr)
    
    End Function
    
    Function regRead(regStr)
    
    	regRead = oShell.RegRead(regStr)
    
    End Function
    
    Function regWrite(val1,val2,val3)
    
    	oShell.RegWrite val1,val2,val3
    
    End Function
    
    Function regDelete(regStr)
    	
    	call oShell.RegDelete(regStr)
    
    End Function
    
    call main()
    I can do without programmatically entering the password, as I can get Outlook Ex to prompt for a password (using "HKCU\Software\Microsoft\Internet Account Manager\Accounts\" & newAccountNum & "\POP3 Prompt for Password") when launched. However, even though it will prompt for a password it isn't remembering the password, i.e. the Remember Password tick box is disabled. Anyone know how to enable it and set it to true??

    Thanks
    Mel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width