Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76

    Access 2010 - Email - Trying to insert a Hyperlink into the VBA of an Onclick Email

    Background:


    I'm working on creating a form where when a single button is clicked an automated email is sent to a certain person.

    Problem:
    In the actual body of the message I would like for there to be a hyperlink in it. How can I add this in the code?

    Private Sub Close_Form_Click()


    DoCmd.SendObject _
    , _
    , _
    , _
    "email.com", _
    , _
    , _
    "Email Subject", _
    "Email Message - "www.google.com", _ (<-- This is what I want to be clickable in the actual email)
    True




    End Sub


    Thank you all!

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    http://www.tutcity.com/access/add-hy...ext.40175.html

    Example of sending an email using sendobject with a hyperlink

  3. #3
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    Thanks Rpeare, but the only problem is that the code in that link you sent is for Outlook... Will this still work with Lotus Notes?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If Lotus Notes understands html code tags, then it should work.

    Instead of referencing Outlook library and Outlook objects, use late binding.

    Review http://www.fabalou.com/VBandVBA/lotusnotesmail.asp
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    Thanks June7, but I am not too familiar with what late binding means.

    Could you be explicit and show what I would need to change in the code below to make it work for my Lotus notes?


    'Public Sub SendNotesMail(Subject as string, attachment as string,
    'recipient as string, bodytext as string,saveit as Boolean)
    'This public sub will send a mail and attachment if neccessary to the
    'recipient including the body text.
    'Requires that notes client is installed on the system.
    Public Sub SendNotesMail(Subject As String, Attachment As String, Recipient As String, BodyText As String, SaveIt As Boolean)
    'Set up the objects required for Automation into lotus notes
    Dim Maildb As Object 'The mail database
    Dim UserName As String 'The current users notes name
    Dim MailDbName As String 'THe current users notes mail database name
    Dim MailDoc As Object 'The mail document itself
    Dim AttachME As Object 'The attachment richtextfile object
    Dim Session As Object 'The notes session
    Dim EmbedObj As Object 'The embedded object (Attachment)
    'Start a session to notes
    Set Session = CreateObject("Notes.NotesSession")
    'Next line only works with 5.x and above. Replace password with your password
    Session.Initialize("password")
    'Get the sessions username and then calculate the mail file name
    'You may or may not need this as for MailDBname with some systems you
    'can pass an empty string or using above password you can use other mailboxes.
    UserName = Session.UserName
    MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
    'Open the mail database in notes
    Set Maildb = Session.GETDATABASE("", MailDbName)
    If Maildb.ISOPEN = True Then
    'Already open for mail
    Else
    Maildb.OPENMAIL
    End If
    'Set up the new mail document
    Set MailDoc = Maildb.CREATEDOCUMENT
    MailDoc.Form = "Memo"
    MailDoc.sendto = Recipient
    MailDoc.Subject = Subject
    MailDoc.Body = BodyText
    MailDoc.SAVEMESSAGEONSEND = SaveIt
    'Set up the embedded object and attachment and attach it
    If Attachment <> "" Then
    Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
    Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
    MailDoc.CREATERICHTEXTITEM ("Attachment")
    End If
    'Send the document
    MailDoc.PostedDate=Now() 'Gets the mail to appear in the sent items folder
    MailDoc.SEND 0, Recipient
    'Clean Up
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set AttachME = Nothing
    Set Session = Nothing
    Set EmbedObj = Nothing
    End Sub

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Late binding means the type of object is not specified in the Dim, just a generic Object is declared.

    I've never used LotusNotes.

    Test this simple procedure, send to yourself:

    Sub SendMail()
    Dim Session As Object 'The notes session
    Dim MailDoc As Object 'The mail document itself
    Dim Maildb As Object 'The mail database

    Set Session = CreateObject("Notes.NotesSession")
    Set Maildb = Session.GETDATABASE("", MailDbName)

    Set MailDoc = Maildb.CREATEDOCUMENT
    Session.Initialize("
    your password")
    MailDoc.Form = "Memo"
    MailDoc.Sendto = "your email address"
    MailDoc.Subject = "subject text"
    MailDoc.Body = "body text"
    MailDoc.SAVEMESSAGEONSEND = True
    MailDoc.PostedDate=Now() 'Gets the mail to appear in the sent items folder
    MailDoc.SEND 0, "
    your email address"
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Maybe a rich text format and some href tags for the body string.
    http://stackoverflow.com/questions/6...from-excel-vba

  8. #8
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    Thanks June7, but that did not work

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What happened - error message, wrong results, nothing?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    Nothing happens... button presses down, but nothing. The form stays open, the email does not pop up... nothing.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You selected [Event Procedure] in the button click event? Then click the ellipsis (...) to open VBA editor. Type code in the procedure.

    Review link at bottom of my post for debugging guidelines.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    Yes lol... that is exactly what I did. I only change what you put in red correct?

  13. #13
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    Sub SendMail()
    Dim Session As Object 'The notes session
    Dim MailDoc As Object 'The mail document itself
    Dim Maildb As Object 'The mail database
    Set Session = CreateObject("Notes.NotesSession")
    Set Maildb = Session.GETDATABASE("", MailDbName)
    Set MailDoc = Maildb.CREATEDOCUMENT
    Session.Initialize ("password")
    MailDoc.Form = "Memo"
    MailDoc.Sendto = "email"
    MailDoc.Subject = "subject text"
    MailDoc.Body = "body text"
    MailDoc.SAVEMESSAGEONSEND = True
    MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
    MailDoc.SEND 0, "email"
    End Sub


    Private Sub Save_Record_Click()

    End Sub


    when i open it back up it adds this bottom part in bold

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The code needs to go between the bold lines but don't use the Sub SendMail() declaration line and don't repeat the End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    Yes, I know... I tried exactly as you have presented it, but it still does not work ;/

    Maybe my work server blocks this from happening?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 04-24-2014, 01:43 PM
  2. Email from Access 2010 (Simple!)
    By floyd in forum Access
    Replies: 9
    Last Post: 10-31-2013, 03:46 PM
  3. how to send email in access 2010
    By nickblitz in forum Access
    Replies: 3
    Last Post: 10-29-2012, 07:28 AM
  4. Add a hyperlink to email message
    By Marianna_Air in forum Forms
    Replies: 2
    Last Post: 08-22-2012, 06:57 AM
  5. How to email a hyperlink using VBA
    By Lockrin in forum Access
    Replies: 1
    Last Post: 07-16-2010, 02:29 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums