+ Reply to Thread
Results 1 to 14 of 14

email object to address in variable row

  1. #1
    Registered User
    Join Date
    02-20-2013
    Location
    Northamptonshire
    MS-Off Ver
    Excel 2003
    Posts
    13

    email object to address in variable row

    hi all,

    I was hoping you could help me with the code for the following:

    (Sheet 1)
    I select B23 / 24 / 25.... etc
    macroassignedbutton_click to do the following:

    Find corresponding email address in O23 / 24 / 25....
    Open embedded object (on Sheet 4) thanks.msg
    Paste email address into To: field of outlook msg
    Send automatically(?)
    Insert "msg sent" into Q23 / 24 / 25....

    display message box to confirm action is complete

    eagerly awaiting your help!

    many thanks

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: email object to address in variable row

    Hi,

    You didn't mention what you want to do with the thanks message. I've assumed this is meant to go in the body of the email so I've used an Input box rather than using a sheet 4 embedded object.

    This is also a sheet event 'before double click' event macro so just double click the relevant row. If you want it instead attached to a button just create anormal module level procedure.
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    02-20-2013
    Location
    Northamptonshire
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: email object to address in variable row

    Hi Richard,

    Yes, the thanks.msg is the body of the email... (also... can you pre-write which mailbox it gets sent from?)

    It would go as a button-click module... will that do anything to the above?

    That's why I wanted the code to simply open a presaved message... as the mailbox will be saved and the body email and subject line already completed in the 'template'.

    the only action i want the code to do is open it... send it the the relevant email address in the row when prompted with a button-click called "send email"

    if the code can then continue on to update the row to say it's sent, and to display a message to the user confirming that - then even better.

    hope this clarifies.
    Last edited by AlixNB; 04-22-2014 at 06:03 AM.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: email object to address in variable row

    Hi,

    Not sure what you mean by 'assign a code to it'. Tell me which line is painted in yellow when you get the Debug. I'm assuming of course that you're using Outlook as your client email software. The original code assumes that the "FROM" is the user who's creating the email. In the version below you can change the sent on behalf of email address..

    In a standard module level procedure which you can attach to a button

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-20-2013
    Location
    Northamptonshire
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: email object to address in variable row

    hi,

    yes = outlook.... (the above looks like you've resolved the outbox for me - thank you)

    the inputbox for the body is what is (while working) not quite right... as the email template I already have is coloured with embedded images and hyperlinks etc... it's not practical to re-write it everytime.

    Is there a way just to send the email object, from dictated box, to whoever is selected, a the click of a macro enabled autoshape (button)?

    please bear with me x

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: email object to address in variable row

    Hi,

    Sorry, but I don't understand what you mean by the 'email object, from dictated box, to whoever is selected'

    Perhaps you'd better upload the workbook you're using and an example of the template you're using.

  7. #7
    Registered User
    Join Date
    02-20-2013
    Location
    Northamptonshire
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: email object to address in variable row

    steMail = Range("O" & ActiveCell.Row)

    .SentOnBehalfOfName = """SenderName"" <senders email address>"
    .to = steMail

    the code above is working great, where it opens an email, sends it to the address stored in column "O", and sends it from the mailbox that I need it to (once I update the name and address as required).

    but instead of opening the email template already kept on sheet 4 (which has been embedded as an object) the code you've helped me with opens up a new - blank email, where your inputbox is asking for the body of the message... rather than loading the embedded email i've already designed.

    is there a way to open the email i have embedded on sheet 4 and send it to steMail = Range("O" & ActiveCell.Row)
    and sent from .SentOnBehalfOfName = """SenderName"" <senders email address>"

    so it's the body of the message that i cant get right, because there is already a template available... i'm just not sure how to get it to open with the code you've helped me with?

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: email object to address in variable row

    Hi,

    I'm spectacularly failing to understand what you mean by your email template on sheet4. What is it exactly? An embedded picture/image?
    As suggested it would be useful if you could upload your workbook.

  9. #9
    Registered User
    Join Date
    02-20-2013
    Location
    Northamptonshire
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: email object to address in variable row

    I can't upload due to server restrictions....

    but, in excel:
    >Insert / Object
    > Create from file / Browse...
    > Tick Display as icon / Okay

    that is how i've embedded the pre-saved outlook email (complete with From:address and all the table layout, images and text)

    So Insead of having a code that opens a new message and asks me to type the body of the email... i want it to open the 'object' ive embedded into sheet 4...

    sorry, i know i'm not explaining it very well.

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: email object to address in variable row

    ...but what is the 'object' in sheet 4?
    A picture inported from a .jpg file? ...something else???

  11. #11
    Registered User
    Join Date
    02-20-2013
    Location
    Northamptonshire
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: email object to address in variable row

    An Outlook .msg file .... so an email template where the to:field is blank (awaiting population from the code/column O)

    according to excel its an 'OLE Object' [whatever that is]?

    Sorry to be a pain

  12. #12
    Registered User
    Join Date
    02-20-2013
    Location
    Northamptonshire
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: email object to address in variable row

    would it be easier/better/cleaner if i change how the .msg is stored?

  13. #13
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: email object to address in variable row

    Hi,

    I'm finding it difficult to visualise exactly what you are describing.

    This is one of those rare occasions when we probably do need to see a picture of what you expect the email to look like. Please upload both the picture and also the workbook you're using.

  14. #14
    Registered User
    Join Date
    02-20-2013
    Location
    Northamptonshire
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: email object to address in variable row

    email img.png

    this is the only way i could do it due to server restrictions

    hope it helps?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Object variable error stumping me: trying to find last row and pass address to cell
    By trillium in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-18-2012, 02:20 PM
  2. Replies: 1
    Last Post: 03-08-2012, 01:57 PM
  3. view email address behind object (picture) in excel
    By iwshim in forum Excel General
    Replies: 0
    Last Post: 03-26-2009, 07:35 PM
  4. search outlook contacts in excel and return email address to variable
    By wotadude in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-27-2008, 06:08 PM
  5. Variable not working as email address
    By Amber_D_Laws in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-17-2006, 02:00 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1