Results 1 to 4 of 4

Thread: Sent an email using another account

  1. #1
    Seeker drocha's Avatar
    Join Date
    Feb 2012
    Location
    Porto, Portugal
    Posts
    5
    Articles
    0

    Question Sent an email using another account



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi,

    I use your code for sending excel data with outlook email and now I want to send the email using another account mail.

    I already tried basic parameters like include in the code .From= "email“ but give me the error that the object doesn’t support that properties. I don't know either if it’s need to configure some parameter in the outlook email.

    From my outlook, I can send the email by using one or other account, that means that i have permission to do that.

    Thank you for you help

  2. #2
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,208
    Articles
    57
    Blog Entries
    14
    Hi there,

    Can you post the code you're using? (Just change all the email domains to "@somedomain.com" so you don't get spammed.)

    Just to be clear here, you have two email accounts configured in Outlook and you can send from either. You'd looking for a way to pick between the two?
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training) or with my book M is for Data Monkey!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  3. #3
    Seeker drocha's Avatar
    Join Date
    Feb 2012
    Location
    Porto, Portugal
    Posts
    5
    Articles
    0
    Hi,

    If I use this code the email is sent from my default account of the outlook.

    'Sending email through outlook
    Set oApp = CreateObject("Outlook.Application")
    Set oMail = oApp.CreateItem(0)
    With oMail
    .To = "mail1domain"
    .CC = "mail2domain"
    .Subject = "Equipamento em stock " & dia & ""
    .HTMLBody = RangetoHTML(rng)
    .Attachments.Add tWB.FullName
    .send
    End With

    But I want that it send from the other account (mail3domain).

    the code that didn't works is:

    'Sending email through outlook
    Set oApp = CreateObject("Outlook.Application")
    Set oMail = oApp.CreateItem(0)
    With oMail
    .From = "mail3domain"
    .To = "
    mail1domain"
    .CC = "
    mail2domain"
    .Subject = "Equipamento em stock " & dia & ""
    .HTMLBody = RangetoHTML(rng)
    .Attachments.Add tWB.FullName
    .send
    End With

  4. #4
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,208
    Articles
    57
    Blog Entries
    14
    Instead of .From try .Sender, or maybe .SenderEmailAddress

    Both of those exist. The .Sender's data type is "AddressEntry", while .SenderEmailAddress is a string like To and CC.
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training) or with my book M is for Data Monkey!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

Posting Permissions

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