PDA

View Full Version : Sent an email using another account



drocha
2012-02-15, 04:50 PM
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

Ken Puls
2012-02-15, 05:50 PM
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?

drocha
2012-02-15, 06:14 PM
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

Ken Puls
2012-02-15, 06:30 PM
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.