+ Reply to Thread
Results 1 to 8 of 8

Email Macro to include 'FROM' field

  1. #1
    Forum Contributor
    Join Date
    11-18-2014
    Location
    England
    MS-Off Ver
    365
    Posts
    132

    Email Macro to include 'FROM' field

    Hi everyone,
    I am using a solution from this web thread as I want to create a button that creates an email in outlook.

    https://www.mrexcel.com/board/thread...utlook.969051/


    I have got it working perfectly. however as I want the email to come FROM another group mailbox I want to know if it is possible to do this? I have tried adding in the line about FROM after the body text instructions as in this example here - however I get runtime error 438 'Object doesn't support this property or method'

    Does this mean adding in the FROM field is not an option?


    [Sub Emailtest()

    Dim olApp As Outlook.Application
    Dim olEmail As Outlook.MailItem


    Set olApp = New Outlook.Application
    Set olEmail = olApp.CreateItem(olMailItem)


    With olEmail
    .BodyFormat = olFormatHTML
    .Display
    .HTMLBody = "UPDATE GOES HERE" & "<br>" & .HTMLBody
    .From = "email address goes here"
    .To = "email address goes here"
    .CC = ""
    .Subject = "Enter Subject text here"

    end sub]
    Last edited by moneypennie21; 04-21-2022 at 09:18 AM.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Email Macro to include 'FROM' field

    You could have a look at the Outlook 'SentOnBehalfOfName' property ...

  3. #3
    Forum Contributor
    Join Date
    11-18-2014
    Location
    England
    MS-Off Ver
    365
    Posts
    132

    Re: Email Macro to include 'FROM' field

    Thanks Cytop, how would I do this with this macro? I have literally learnt how to do this today so am new to the email macro game!

  4. #4
    Forum Contributor
    Join Date
    02-25-2022
    Location
    Dallas, Texas
    MS-Off Ver
    Office 365
    Posts
    174

    Re: Email Macro to include 'FROM' field

    I don't think the MS Exchange servers allow this. It is a security issue. Email spoofing. I tried to do this a while back and ended having to create another 365 account.

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Email Macro to include 'FROM' field

    That is the problem - this is not a simple question to answer because Outlook settings will also affect what you can do with VBA, in particular SendOnBehalfOf can only be used with Exchange accounts to send from addresses for which you have SendAs permissions.

    To try it, just replace the '.FROM' in your code with '.SENDONBEHALFOF' (Not forgetting whichever email address you want to use) - it can only error, and probably will.

  6. #6
    Forum Contributor
    Join Date
    11-18-2014
    Location
    England
    MS-Off Ver
    365
    Posts
    132

    Re: Email Macro to include 'FROM' field

    ok, I tried using the send on behalf of and it did open up the email but had not changed the name in the FROM field and I did also get a runtime error. So it appears from the sound of it that this is not possible. I thought it was a longshot but always ask the Excel Hivemind first! Thanks for trying

  7. #7
    Forum Contributor
    Join Date
    02-25-2022
    Location
    Dallas, Texas
    MS-Off Ver
    Office 365
    Posts
    174

    Re: Email Macro to include 'FROM' field

    I needed to do this because I needed to send email messages from a generic account. I added generic 365 account. I then added the generic account to Outlook on the desktop. So in VBA I specified to send email from 2nd account.

    Please Login or Register  to view this content.

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Email Macro to include 'FROM' field

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code in post #1.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ 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] Email Send Macro - 0 pulling into CC field when no email address present
    By toriwoo86 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-26-2021, 02:18 PM
  2. 1 email per email address, include cell value in email subject
    By melody10 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-31-2019, 10:27 PM
  3. VBA Macro range into email to include the conditional color coding on worksheet
    By draconosjb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-18-2016, 04:08 PM
  4. [SOLVED] Email macro - include data from cells in subject
    By horsefish01 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-20-2015, 05:24 PM
  5. Email macro, include variable in body & add default outlook signature
    By promithius in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2013, 09:05 AM
  6. [SOLVED] Macro: Get Email Address from CC field (Outllok email msg)
    By rampal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2013, 06:44 PM
  7. Macro to create workbooks with key field name and automatic email
    By su_nil in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2010, 09:16 AM

Tags for this Thread

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