Results 1 to 7 of 7
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185

    Link in email to send back to me

    Hi Guy's I thought i had achieved the following but not quite but not far away



    I am after sending an email out where in the email body it will have a choice of 2 link s to click, once clicked by the recipient, it comes back to us with the result in the return mail

    I have got as far as below but clicking the link in the email doesn't generate and send ?

    Code:
    If Me.cboStatus = "Stock" Then    If Me.Value > 0 Then
            If Me.EMail <> "" Then
            myEmail = Me.EMail
            a = TOD & " " & myClient
            b = "Thank you for using our services recently to remove your redundant product."
            c = "It is very important to us as we pride ourselves in serving all clients with a great service, we are just wanting to check to make sure that the full procedure was carried out according to plan."
            d = "1: Did you receive your payment of £" & Me.Value & " ?"
            e = "2: Did you receive your free gift ?"
            f = "To prevent having to write out another email, simply click on the relevant link below to confirm all arrangements such as payment received ok and you were rewarded with your free gift."
            g = "Finally, we just want to say thank you again for using our services and it was an absolute pleasure to assist, please stay safe."
            h = "With Our Kindest Regards"
            j = myName
            Return1 = "Thank you very much, I can confirm that I received my " & "£" & Me.Value & " along with my free gift"
            Return2 = "Thank you, the engineer that arrived did make an adjustment to the arrangements that we agreed with yourselves."
            Return3 = "What was the adjustments made ?"
            mySubj = "Courtesy Email Ref " & Me.RecordNo & " Item Removal"
            Opt1 = "Click here > "
            Opt2 = "Click here > "
                Set oEmailItem = oOutlook.CreateItem(olMailItem)
                With oEmailItem
                    Set OutAccount = oEmailItem.Session.Accounts.Item(2)
                    .To = myEmail
                    .Subject = mySub
                    .HTMLBody = a & "<br>" & "<br>" & b & "<br>" & "<br>" & c & "<br>" & "<br> " & _
                    d & "<br>" & e & "<br>" & "<br>" & f & "<br>" & "<br>" & g & "<br>" & "<br>" & _
                    i & "<br>" & "<br>" & _
                    "<a href=”mailto:info@ouremail.com”" & Opt1 & ensp & Return1 & "<br>" & "<br>" & _
                    Opt2 & ensp & Return2 & "<br>" & "<br>" & h & "<br>" & "<br>" & _
                    j & "<br>" & "<br>" & _
                    "<P><IMG border=0 hspace=0 alt='' src='file://T:/Email Signature.jpg' align=baseline></P>" & "<br>" & "<br>" & _
                    "<FONT color=#0000CD>" & eDisc & "<br>" & "<FONT color =#0000CD>" & eDisc2
                    .SendUsingAccount = OutAccount
                    .Display
                End With
            End If
        End If
    End If
    RESULT BELOW BUT WANTING OPT1 to reply with Return1 and OPT2 to reply with Return2 ?

    Click image for larger version. 

Name:	SnipImage.JPG 
Views:	28 
Size:	57.3 KB 
ID:	46229

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    did you ever get this to work? Unless you are using global variables there's a whole lot of undeclared ones plus at least 1 that has no value but is referred to (i) and maybe a bunch more stuff. Then there is the double double quotes (sort of) after the end of your mailto tag, and no ending html character (>) for it and both links are wrapped in the same mailto tag. In fact, your valediction and name is part of that mailto link.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185
    Hi Micron, thank you yes, kind of copied and pasted code from elsewhere on the system and done some adapting, i think it's a mixture of lack of understanding along with being side tracked !!!!

    Thank you anyway, i am going to paste a new one, wondering how can i copy and paste from excel to access

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Well, I spent about 2 hours on it just because I wanted to refresh what I knew about html email coding from vba. Might as well post it for your perusal. Probably some unwanted advice/comments there too - just ignore those. Note that I embellished the email tag somewhat by adding subject line and body text attributes.

    Code:
    Function DMTDave()
    'obviously use the original procedure name. Converted to function because I have no button to call this
    'values/tests for which I have no form/table etc. are just hard coded or rem'd out as ''
    
    Dim myEmail As String
    Dim a As String, b As String, c As String
    Dim Return1 As String, Return2 As String, Return3 As String
    Dim strMailto1 As String, strMailto2 As String
    Dim mySubj As String ', Opt1 As String
    Dim oOutlook As Outlook.Application
    Dim oEmailItem As Object
    
    If 1 = 1 And 1 > 0 Then 'obviously had to design my own IF test
       myEmail = "somebody@somewhere.com"
       a = "Dear Mr. Jones; <P>"
       b = "Thank you for recently using our services to remove your redundant product. <P>"
       b = b & "It is very important to us because we take great pride in providing all clients with exceptional service. "
       b = b & "We would like to ensure that the full procedure was carried out according to plan.<P>"
       b = b & "1: Did you receive your payment of £" & 10 & "?<br>"
       b = b & "2: Did you receive your free gift? <P>"
       b = b & "Please click on one of the options below to confirm all arrangements such as reciept of your payment "
       b = b & "and your free gift.<P>"
       b = b & "In closing we just want to say thank you again for using our services. It was an absolute pleasure to assist you. "
       b = b & "Please stay safe! <P>"
       c = "Micron"
       
       Return1 = "I can confirm that I received my " & "£" & 10 & " along with my free gift. Thank you."
       
       'you don't agree WITH something, you agree TO it. You agree WITH people (although certain foods might not agree with you!)
       Return2 = "The engineer that arrived adjusted the arrangements we had agreed to. Thank you."
       Return3 = "What were the adjustments made?"
       
       strMailto1 = "<a href='mailto:somebody@somewhere.com?Subject=Option1 Chosen&body=" & Return1 & "'>"
       strMailto2 = "<a href='mailto:somebody@somewhere.com?Subject=Option2 Chosen&body=" & Return2 & "'>"
       ''mySubj = "Courtesy Email Ref " & Me.RecordNo & " Item Removal"
       mySubj = "Courtesy Email Ref 123456 Item Removal"
       ''Opt1 = "Click here> " less concatenating of html if you just use the literal string "click here"
       ''opt2 = "Click here > " 'redundant - it's the same value
       Set oOutlook = New Outlook.Application
       Set oEmailItem = oOutlook.CreateItem(olMailItem)
          With oEmailItem
             ''Set OutAccount = oEmailItem.Session.Accounts.Item(2)
             .To = myEmail
             .Subject = mySubj
             .HTMLBody = a & b & _
              strMailto1 & "Click here: " & Return1 & "</a><P>" & _
              strMailto2 & "Click here: " & Return2 & "</a>" & _
             "<P><IMG border=0 hspace=0 alt='' src='file://T:/Email Signature.jpg' align=baseline></P>" & _
             "<FONT color=#0000CD>" & "<br></font>"
             .HTMLBody = .HTMLBody & "With Our Kindest Regards,<P>" & c
             ''.SendUsingAccount = OutAccount
             'Debug.Print .HTMLBody
             .Display
          End With
       End If
    
    End Function
    Last edited by Micron; 09-28-2021 at 01:48 PM.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185
    Hi Micron, brilliant, thank you, I will take a good look at your version as it's not perfect what i done but, it works but could be better coded, although i marked as solved, i will review your version and likely test/use yours

    Thank you

    Just about post another one that i am struggling with (mainly understanding)

  6. #6
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185
    Hi Micron, yes just used your version, perfect thank you, works fantastic

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Glad to hear it!
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 07-12-2018, 05:38 AM
  2. Replies: 2
    Last Post: 05-23-2016, 01:28 PM
  3. Replies: 3
    Last Post: 12-28-2015, 04:11 PM
  4. Replies: 5
    Last Post: 05-07-2014, 09:25 AM
  5. Replies: 5
    Last Post: 05-27-2013, 09:34 AM

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