Link to home
Start Free TrialLog in
Avatar of bfuchs
bfuchsFlag for United States of America

asked on

Email forgotten PWD from Access

Hi Experts,

I am in middle of enforcing a PWD for users who want to open our Access system, and the way its being setup is that each user have their own password.

Now I need to have a way of handling in case user forgot their PWD.

Was thinking of having a button "forgot my password", and in that case an email will be sent with their pwd.

In order to ensure no user request someone else's pwd, I would save along with their pwd the IP address of that pc, so at the time user logs into the system and clicks forgot my pwd, if the IP is not the same it will not do anything.

Just having some issues:

1- Users may realize it has to do with which pc they use.
2- Since email will be sent from the local pc they are on, it will remain there on sent items.
3- By Using SendObject it will display the contents of the email and wait for user to click send, in that case user already saw the pwd, so I have not accomplished anything by sending an email, I can for this money popup a msg box..
4- If I use the outlook programming model instead, I will have to add reference to Outlook library and this may cause some issues in our app.

What are my options?
SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bfuchs

ASKER

Hi Experts,
Re security, I'm currently using the following function to encrypt the data, saw it on a link someone suggested on EE
Function XorC(ByVal sData As String, ByVal sKey As String) As String
    Dim l As Long, i As Long, byIn() As Byte, byOut() As Byte, byKey() As Byte
    Dim bEncOrDec As Boolean
     'confirm valid string and key input:
    If Len(sData) = 0 Or Len(sKey) = 0 Then XorC = "Invalid argument(s) used": Exit Function
     'check whether running encryption or decryption (flagged by presence of "xxx" at start of sData):
    If Left$(sData, 3) = "xxx" Then
        bEncOrDec = False 'decryption
        sData = Mid$(sData, 4)
    Else
        bEncOrDec = True 'encryption
    End If
     'assign strings to byte arrays (unicode)
    byIn = sData
    byOut = sData
    byKey = sKey
    l = LBound(byKey)
    For i = LBound(byIn) To UBound(byIn) - 1 Step 2
        byOut(i) = ((byIn(i) + Not bEncOrDec) Xor byKey(l)) - bEncOrDec 'avoid Chr$(0) by using bEncOrDec flag
        l = l + 2
        If l > UBound(byKey) Then l = LBound(byKey) 'ensure stay within bounds of Key
    Next i
    XorC = byOut
    If bEncOrDec Then XorC = "xxx" & XorC 'add "xxx" onto encrypted text
End Function

Open in new window


What do you say for it, is it secure enough?

Re sending email options mentioned, I will have to test those & let you know.

Thanks,
Ben
<<What do you say for it, is it secure enough?>>

 Have no idea, but I would think not for anything but the casual user.   I did do some work with exclusive OR encryption about 30 years ago, and it was light weight even back then.

 You need triple DES, AES, or the like to be secure.

Jim.
Avatar of bfuchs

ASKER

@David,
Tried the following from that link
Public Sub TestCDO()
Dim nmo1 As Object


Set nmo1 = CreateObject("CDONTS.NewMail")
    nmo1.Subject = "t"
    nmo1.from = "someemail@test.org"
    nmo1.BodyFormat = 0
    nmo1.MailFormat = 0
    nmo1.Body = "test"
    nmo1.To = "someemail@test.org"
    nmo1.Send
    Set nmo1 = Nothing
End Sub

Open in new window

And I get the attached.

When I try the following it works
Set ola1 = New Outlook.Application

Set nmo1 = ola1.CreateItem(olMailItem)

Open in new window

However I stay with the two issues mentioned in OP, the requirement for adding Outlook reference and the ability of users to see it on send items..

when I try the following
Dim mail    As CDO.Message
    Dim config  As CDO.Configuration
    
    Set mail = CreateObject("CDO.Message")
    Set config = CreateObject("CDO.Configuration")
    
    config.Fields(cdoSendUsingMethod).Value = cdoSendUsingPort
    config.Fields(cdoSMTPServer).Value = "smtpout.secureserver.net"
    config.Fields(cdoSMTPServerPort).Value = 3535
    
    config.Fields.Update
    
    Set mail.Configuration = config

Open in new window

I get the second attachment while trying to send.


Thanks,
Ben
Untitled.png
Untitled1.png
Avatar of bfuchs

ASKER

Hi Experts,

@Jim,
I'm trying to follow what you posted in another thread..
https://www.experts-exchange.com/questions/21958236/How-do-I-use-BLAT-from-VBA.html#
Public Sub testblat()
x = Shell("C:\Users\bfuchs\Downloads\blat3217_64.full\blat3217\full\blat.exe -to MySelf@thejnet.com -f MyOtherEmail@Thejnet.com -server smtp.secureserver.net -port 3535 -body Test message -pw MyPWD -u MyUser")
End Sub

Open in new window

However so far I was not able to get this working, perhaps you can help figure out what's missing here..?

FYI- We use GoDaddy for our email server and I copied all settings that I have for my outlook to work with it.

Thanks,
Ben
<<However so far I was not able to get this working, perhaps you can help figure out what's missing here..?>>

 There are any number of things that might be going wrong, so what I will offer is troubleshooting steps.

  The beauty of using BLAT is that it is a command line utility.   So my suggestion would be to start with that; doing it manually from the command line.

 Drop to a command prompt and type the command out (or paste it in using the menu).   Try a simple message first and build up the command bit by bit (i.e. don't use a file for the body right off, but just a simple text string) that you need until you have the complete command working.  You'll quickly find out what it doesn't like and because your working in the command window and will be able to see the error.   There should be a switch for "verbose" logging, make sure you use it.

 Once you have it working, try putting it in a batch file and execute the batch file from the command window.   This helps you get things right like delimiters, which can mess you up when suing Shell().

 Once the batch file is working, then you can either call the batch file with Shell() from VBA, or cut and paste the statement for use in VBA with Shell().

Jim.
Avatar of bfuchs

ASKER

@Jim,

Thanks for those debugging tips, I was finally able to get them both to work as follows

CDO
Public Sub SendEmail()
    Dim imsg As Object
    Dim iconf As Object
    Dim flds As Object
    Dim schema As String

    Set imsg = CreateObject("CDO.Message")
    Set iconf = CreateObject("CDO.Configuration")
    Set flds = iconf.Fields

    ' send one copy with SMTP server (with autentication)
    schema = "http://schemas.microsoft.com/cdo/configuration/"
    flds.Item(schema & "sendusing") = cdoSendUsingPort
    flds.Item(schema & "smtpserver") = "smtpout.secureserver.net."
    flds.Item(schema & "smtpserverport") = 3535
    flds.Item(schema & "smtpauthenticate") = cdoBasic
    flds.Item(schema & "sendusername") = "MyEmailAdd"
    flds.Item(schema & "sendpassword") = "MyPWD"
    flds.Item(schema & "smtpusessl") = False
    flds.Update

    With imsg
        .To = "AnyEmail"
        .From = "AnyEmail"
        .Subject = "Test Send"
        .HTMLBody = "Test"
        '.Sender = "Sender"
        '.Organization = "My Company"
        '.ReplyTo = "address@mycompany.com"
        Set .Configuration = iconf
        .Send
    End With

    Set iconf = Nothing
    Set imsg = Nothing
    Set flds = Nothing
End Sub

Open in new window


Blat
x = Shell("C:\Users\bfuchs\Downloads\blat3217_64.full\blat3217\full\blat.exe -to MyEmailAdd -f MySecondEmailAdd t -server smtpout.secureserver.net. -port 3535 -subject testsubject -body Test -pw MyPWD -u MyUserName")

Open in new window


Now my question,
Besides the fact that CDO requires an additional reference to MSFT CDO for Windows 2000, and blat requires I copy that exe file to each PC, what are the other pros/cons from each of those utilities?

Thanks,
Ben
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bfuchs

ASKER

Thank you very much experts for all your help!