Results 1 to 5 of 5

Thread: Can't Correct Code Send Email via Outlook using Excel Code
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    MrExcel MVP Anne Troy's Avatar
    Join Date
    Feb 2002
    Location
    Westwood NJ
    Posts
    2,597
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Can't Correct Code Send Email via Outlook using Excel Code

    I'm using Outlook locally with 2 accounts.
    I want to send emails programatically using the "non-default" account.
    I checked out "SendUsingAccount", but wasn't able to make that work.
    Anyone know the syntax?

    Here's my code:

    Code:
        On Error Resume Next
        With OutMail
            '.From = Range("fromwho").Text this doesn't work, even if it's hard-coded email addy
            .To = "anne@annetroy.com"
            .CC = Range("driveremail").Text
            .BCC = "anne@annetroy.com"
            .Subject = Range("spsubj").Text
            .Body = strbody
            .Display   'or use .Send
        End With
        On Error GoTo 0
    ~Anne Troy

  2. #2
    Administrator starl's Avatar
    Join Date
    Aug 2002
    Location
    Everywhere!
    Posts
    5,859
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Can't Correct Code Send Email via Outlook using Excel Code

    Hi Anne, long time no see!

    have you tried using .SendUsingAccount?

    Code:
    Outmail.SendUsingAccount = OutApp.Session.Accounts.Item(1) 'might require Set at the beginning for 2016 and newer....
    The "1" is the number of the account to use. Ron has an example of this at his site:
    https://www.rondebruin.nl/win/s1/outlook/account.htm

  3. #3
    MrExcel MVP Anne Troy's Avatar
    Join Date
    Feb 2002
    Location
    Westwood NJ
    Posts
    2,597
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Can't Correct Code Send Email via Outlook using Excel Code

    Hey, girl!!

    Yep. I tried that as stated in my post.
    I think I missed the (1) part....

    This worked:

    Code:
        On Error Resume Next
        With OutMail
        Set .SendUsingAccount = OutApp.Session.Accounts.Item(2)
    Thanks!!!
    ~Anne Troy

  4. #4
    Administrator starl's Avatar
    Join Date
    Aug 2002
    Location
    Everywhere!
    Posts
    5,859
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Can't Correct Code Send Email via Outlook using Excel Code

    ugh - sorry I missed that. Was so excited to see, wasn't reading clearly
    Glad you got it figured out!

  5. #5
    MrExcel MVP Anne Troy's Avatar
    Join Date
    Feb 2002
    Location
    Westwood NJ
    Posts
    2,597
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Can't Correct Code Send Email via Outlook using Excel Code

    Dang. lost my reply. Here it is again:

    If you'd seen it, you might not have made me try it again!

    GREAT to see you as well.
    ~Anne Troy

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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