Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Lounger
    Join Date
    Apr 2001
    Location
    Lakeland, Florida 33805-9595
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Email from hyperlink (Access 2000)

    I have two fields on a form for e-mail-1 and e-mail-2. I tried clicking on the link while Outlook is open and nothing happens. Outlook is default e-mail.

    Should I use two bottons with coding?

  2. #2
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Maine, USA
    Posts
    258
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email from hyperlink (Access 2000)

    I have not totally figured out the hyperlink data type, but it seems like if you
    want to create an e-mail (rather than link to a web page) you have to enter the
    address with "mailto:" in front of it (no spaces in the whole thing - for example, mailto:address@isp.net). When I do
    that, my e-mail fields work to generate e-mail, and when I don't, nothing
    happens, just like you describe.

    However, this is a problem if you want to - as I do - also use the data in that
    field for mailings to multiple addresses because "mailto:" is not really part of
    the address and so when you string them together, the e-mail program can't read
    them anymore. It would also obviously be weird if you wanted to print those addresses in reports listing people's e-mail addresses.

    That's as far as I've gotten (aside from a few failed experiments to address the problems I identified). Hope it helps.
    -cynthia

  3. #3
    Lounger
    Join Date
    Apr 2001
    Location
    Lakeland, Florida 33805-9595
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email from hyperlink (Access 2000)

    Thanks. That works. For the old records:
    What I have done is tab to the field email1 and pressed F2 and replaced "http://" with "mailto:". Copied "mailto:" to clipboard and tabbed to the next email2 and replace the "http://" with what is in memory.

    I had to do for each record.

    But no coding.

  4. #4
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Maine, USA
    Posts
    258
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email from hyperlink (Access 2000)

    I had tried to do it with code, but even though the code successfully put the
    "mailto:" into the address, the hyperlink function still didn't work unless I
    did it manually - as you did. Seems like it should be simpler than that, but that's the best I've come up with so far.

    As I already mentioned it does mess up the addresses for either printing or bulk mail - so I'm still looking for a better solution - I want to be able to either send an e-mail to the individual OR include the individual's address in a group mailing - and I also print the addresses in a membership directory.

    -cynthia

  5. #5
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Maine, USA
    Posts
    258
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email from hyperlink (Access 2000)

    Thank you! I'll try that.
    For my group mailings, I have been using a query which I then "select all" and copy and paste into the BCC field of the e-mail message (Outlook Express) - and I just have to remember to delete the field name from the front of the list. IT works fine, but it isn't very intuitive for other users using my database.

    -cynthia

  6. #6
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Maine, USA
    Posts
    258
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email from hyperlink (Access 2000)

    I have put this code in, but when it gets to the line
    OpenOutlook (Me.HomeEmail) (where "HomeEMail" is the field for the e-mail address)
    I get an error message "Sub or Function not defined"

    When I go to Tools, the choice of "References" is not available (it's gray). Does this mean my computer person neglected to install this function? (I normally do my own installations, but because I run both Access 97 and 2000, I let the pros handle this one!)

  7. #7
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email from hyperlink (Access 2000)

    References is grayed out because you haven't stop the code.
    Francois

  8. #8
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Maine, USA
    Posts
    258
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email from hyperlink (Access 2000)

    Merci! Fixed that problem. I can access the references. But I'm still getting the error message.
    Here's what I've tried, and I think this is the last question:

    I am using Outlook 98 - I do not have Outlook 2000 installed (It won't share an address book with Outlook Express, which I need it to do). I am now suspecting that this is the problem. Here is what I've tried and what happens:

    When I go to the references I have an "Outlook 98 Type Library" (checked)
    "Microsoft Office 9.0 Object Library" (checked)
    "Micorsoft Outlook Express 5.0 Type Library" (when I check it and click "ok" I get an error message "Error in loading DLL", so it is not checked)
    There isn't a "Microsoft Outlook 9.0 Object Library" so I can't check it.

    I found some code for a similar function in one of my books. That code sets up a public module to launch the e-mail mesage, and then calls the public module from the form event. When I run THAT code, it stops on the first line of the public module "Public olkApp as Outlook.Application" and I get the error message: "compile error: Can't find project or library"
    When I click "help" on the error message I get a blank box.

    Am I going to have to install Outlook 2000 to get this to work? I'm assuming that since it won't even load the Outlook Express Library (as mentioned above) that I should abandon that option.

    Thanks very much for the assistance.

  9. #9
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email from hyperlink (Access 2000)

    I was assuming that if you have Access 2000, you also have Outlook 2000.

    I have try in the past to create e-mail from Access 2000 into Outlook Express but without success.

    About Outlook 98, I don't know if you can mix automation between Access 2000 and Outlook 98. Maybe some one else can answer this.
    Francois

  10. #10
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Email from hyperlink (Access 2000)

    Hi,
    I think your problem lies in the fact that OpenOutlook is a user-defined function, not a built-in one. Unless you have the code for it in a module somewhere, you will get that error. If Francois posts the code he uses for it, you may well find that it will work with Outlook 98 too.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  11. #11
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email from hyperlink (Access 2000)

    It seems Rory <img src=/S/bravo.gif border=0 alt=bravo width=16 height=30> better know what I have written in the past than myself. <img src=/S/blush.gif border=0 alt=blush width=15 height=15>

    Here is the openoutlook function.

    <pre>Sub openoutlook(txtTO As String)
    Dim myOLApp As New Outlook.Application
    Dim myOLItem As Outlook.MailItem
    Set myOLItem = myOLApp.CreateItem(olMailItem)
    myOLItem.To = txtTO
    myOLItem.Display
    End Sub
    </pre>

    Francois

  12. #12
    Lounger
    Join Date
    Apr 2001
    Location
    Lakeland, Florida 33805-9595
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email from hyperlink (Access 2000)

    Cynthia,
    You would have to make a button with an event procedure to add "mailto:" to the e-mail address.
    If you make it a hyperlink it adds "http:// " so it should just me a plain text box.
    I don't know the code to try as I haven't done it.
    Paul

  13. #13
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Maine, USA
    Posts
    258
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email from hyperlink (Access 2000)

    Ok - I'm still trying things. Yes - it sure is easy to forget what one has done with some code in the past!

    I added Francois' code and now it stops at "openoutlook" in the event procedure and I get the error message "expected variable or procedure, not module". Did I put it in the wrong place?

    Here is the code I put in my event procedure on the form:

    Private Sub HomeE_mail_DblClick(Cancel As Integer)

    'Open Outlook and put this email address in the "to" field
    RunCommand acCmdSaveRecord
    If Not IsNull(Me.[HomeE-Mail]) Then
    OpenOutlook (Me.[HomeE-Mail])
    End If

    End Sub

    This is the code I put in the module:

    Sub OpenOutlook(txtTO As String)
    Dim myOlApp As New Outlook.Application
    Dim myOLItem As Outlook.MailItem
    Set myOLItem = myOlApp.CreateItem(olMailItem)
    myOLItem.To = txtTO
    myOLItem.Display
    End Sub

    I notice in the example I have been trying to work from this afternoon that they also have a line up in the "defninitions" in the module, so I tried putting up there:
    Public olkApp As Outlook.Application
    But I still get the same error message when I double-click the field.

    Here is the example from the book, in case it gives anyone any ideas:
    This is their module (obviously this code runs in a different database than the one described above, and they are doing a couple additional things here - like filling in the subject line):
    Option Compare Database
    Option Explicit

    Public olkApp As Outlook.Application
    Public olkNameSpace As Outlook.NameSpace


    Sub ap_CreateOLMailItem(strRecipient As String, strSubject As String)

    Dim objMailItem As Outlook.MailItem

    Set olkApp = New Outlook.Application

    Set olkNameSpace = olkApp.GetNamespace("MAPI")
    Set objMailItem = olkApp.CreateItem(olMailItem)

    With objMailItem
    .To = strRecipient
    .Recipients.ResolveAll
    .Subject = "This is the subject line"
    .Body = "Here is the body"
    .Display
    End With

    Set objMailItem = Nothing
    Set olkNameSpace = Nothing
    Set olkApp = Nothing

    End Sub

    And here is there code for the button on the form (they are using a button, not a text field)

    Private Sub cmdOutlookMailItemDemo_Click()

    ap_CreateOLMailItem "v-sbark", "Testing"

    End Sub

    As I mentioned, this code from the book gives me the error message: "Can't find project or library"

    Any more ideas? I'm determined to get this to work! These Office products are SUPPOSED to work together. I don't see any point in maintaining the membership of our organization in both our database and my e-mail address book - which doubles the possibility of missing updates.

    Merci beaucoup (thank you very much)!
    -cynthia

  14. #14
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email from hyperlink (Access 2000)

    What name do you give to the module ?
    I suspect OpenOutlook. If so rename it to whatever you want, but not the name of a sub or function.
    Francois

  15. #15
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email from hyperlink (Access 2000)

    To open a new message in Outlook 2000 from Access 2000, create a textbox containing the email address of the recipient on a form.
    Name that textbox txtEmail

    Insert the following code in the DblClick event of the textbox txtEmail.
    <pre>Private Sub txtEmail_DblClick(Cancel As Integer)
    RunCommand acCmdSaveRecord
    If Not IsNull(Me.txtEmail) Then
    OpenOutlook (Me.txtEmail)
    End If
    End Sub
    </pre>


    Make a new sub in a Module. Name this module anything you want, but not openoutlook
    Insert the following code in this module:
    <pre>Sub openoutlook(txtTO As String)
    Dim myOLApp As New Outlook.Application
    Dim myOLItem As Outlook.MailItem
    Set myOLItem = myOLApp.CreateItem(olMailItem)
    myOLItem.To = txtTO
    myOLItem.Display
    End Sub
    </pre>


    In the code window, click Tools/references and see if Microsoft Outlook 9.0 Library Object is checked. If not check it.

    Double clicking on the controls will open a new email message with the To field already filled in with the content of txtEmail.
    Francois

Page 1 of 2 12 LastLast

Posting Permissions

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