Full Version: format a text feild for email addresses
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
minnesota1972
Hi all

In my DB I have a table of contact info. One of my fields is an email address. Is there a way to format that text box on my form so if the Db user clicks on it, their email client would open with that email address in the "send to". Or if not their defulat email client, maybe some tiny apps like QM

If you don't know what QM is: it's here:
http://pyric.org/qm/
QM

Does that question make sence. What's happening in my DB now is if the user wants to send an email to the contact; they must copy the email address from the text box, strat their client, open a new message window and paste the address in the "Send To". I'm hoping to replace all that with on On Click

John
fredrisg
I just put the email address in a textbox . . . and have a cmd button next to it with this code:
CODE
Private Sub cmdSendEmail_Click()

On Error GoTo Err_cmdSendEmail_Click

'----------------------------------------------------------------------------
'Started: 6/28/05
'
'
'
'
'
'
'----------------------------------------------------------------------------
    
                  
    If IsNull(txtConsultantEmail) Or txtConsultantEmail = "" Then
        
        Dim lstrMsg As String
        Dim lintResponse As Integer
        lstrMsg = "Missing email address . . . send cancelled."
        lintResponse = MsgBox(lstrMsg, vbOKOnly + vbInformation, "No Email Address")
            Exit Sub
        
    Else
        
        On Error Resume Next                    '7/6/05
        DoCmd.SendObject acSendNoObject, , , _
        txtConsultantEmail, , , "Your subject text goes here", "Enter your message here ....", True

    End If

    
Exit_cmdSendEmail_Click:
    Exit Sub

Err_cmdSendEmail_Click:
    DoCmd.Hourglass False
    Dim lstrErrMsg As String
    Dim lintErrResponse As Integer
    lstrErrMsg = "Error has occured in frmConsultant_cmdSendEmail_Click. Please " & _
                 "advise System Administrator if problem persist. Error: " & Err.Number & " - " & _
                 Err.Description
                
    lintErrResponse = MsgBox(lstrErrMsg, vbOKOnly + vbInformation, "Error")
    Resume Exit_cmdSendEmail_Click
End Sub


I got this code from another poster here at this forum. Works fine . . .

If the email client isn't open, you get an error message . . .but after clicking OK, the email client opens anyway . . .and works as expected. Not sure how to surpress this message.

Steve
minnesota1972
Hi

That's some sure tasty code! Yum! Thanks alot!

There one thing I don't understand: does it open the default client or just Outlook? Do you know what happens if the user only has outlook express? Or some other client like Eudora or foxmail?

John
fredrisg
John,

Not 100% sure . . . haven't used it much . . . was just playing around and it worked with our default email (Lotus Notes).

I believe there is more code you can use to open a specific client . . . try searching the archives here.

Steve
minnesota1972
Hi to all

The above code works great! Thanks to Steve for it. Does anyone know if it's possible to send a mass email from a DB.

IE: If I have a table with anywhere from 12 to 200 contacts, and one of my feilds is an email address, is there a way to email them all at the same time.

The above code only lets me email one person at a time.

Steve, if you're still out there, do you have any input on this one? Does anyone?

John
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.