Reset Password

Djblois

Registered User.
Local time
Today, 15:13
Joined
Jan 26, 2009
Messages
598
I created a login screen for my users, that they need to enter their login and password in order to enter the database. Now I am creating it so if they forget their password then it will email me that they need it reset. I am testing this code, which works in Excel:

PHP:
Sub emResetPassword()
     
    Dim OL As Object, EmailItem As Object
     
    Set OL = CreateObject("Outlook.Application")
    Set EmailItem = OL.CreateItem(0)
    
    With EmailItem
        .To = "Dblois@atalanta1.com"
        .Body = "I forgot my Password - Please Reset it!"
        .Subject = "Password Reset"
        .Send
    End With
     
    Set OL = Nothing
    Set EmailItem = Nothing
     
End Sub

I can't get it to work. It keeps crashing on the .Send line saying:

Application-defined or Object-defined error
 
Only a guess but do you need to set a reference to outlook from access?
 
Isn't this the reference:

Set OL = CreateObject("Outlook.Application")
 
You shouldn't need a reference since you're using late binding. If you change that to

.Display

does it display the email?
 
Yes

.Display is working. Why won't .send work?
 
Well, I'm in speculation mode now, as I don't really have a good answer. Can the user send an email normally from Outlook?
 
Yes, I can send it by itself or also if I run the same code in excel it works.
 
I just tested (Access 2000) and it worked fine, as I expected it would. I did have to respond to the Outlook security warning, but it doesn't sound like you're getting that far.
 
No, I am not. I get the security warning when I run that code in Excel but Access is just giving me an error. Does anyone else have Access 2007 to see if it is an issue with the 2007 version? Also is there another way to do this same thing?
 
I just tested with Access 2007; it worked fine there too. You could try using SendObject.
 
Try This

Code:
Sub emResetPassword()
With CreateObject("Outlook.Application").CreateItem(0)
        .To = "[EMAIL="Dblois@atalanta1.com"]Dblois@atalanta1.com[/EMAIL]"
        .Subject = "Password Reset"
        .Body = "I forgot my Password - Please Reset it!"
        .Send
    End With
 

Users who are viewing this thread

Back
Top Bottom