Outlook VBA - Select Default Account

Soldato
Joined
19 Jan 2003
Posts
17,539
Location
Bristol, UK
Hi all,

Putting together a couple of Macros within Outlook 2010. I've recreated the New, Reply, Reply All and Forward Buttons so that they always send emails via a specified account.

It's so that when a user replies to an email stored in a shared mailbox, the reply is sent via their own email account, not from the shared mailbox.

I am currently specifying this desired account by string in the code, e.g. "[email protected]"

In all instances of this macro being used, the desired account is also the default account.

Can I bypass the requirement of my string and manual declaration in favour of selecting the "default account".

This would save me a lot of time rolling this macro out to the 10 or so required users workstations.

Thanks in advance.
 
Associate
Joined
14 Mar 2007
Posts
1,667
Location
Winchester
hhmm we have had this problem and we couldn't come to a real solution. Assuming we are talking about the same thing you can only actually change the actual account being sent from for the exchange server.

As we could not get appropriate permissions from IT to change this stuff on the fly we fudged it.

We fudged it by simply setting the .sentonbehalfof property to the mailbox we needed, so:

With olMail
.Subject = "MEH: " & Date & " (" & clsSave.DBid & ")"
.Body = "Please find attached a gift request for " & clsSave.ClientName & ". Could you please respond with the order and tracking numbers as soon as possible." & vbNewLine & vbNewLine & "regards"
For i = 0 To UBound(tempArray, 1)
.Recipients.Add tempArray(i)
Next i
.Recipients.ResolveAll

.Attachments.Add clsSave.SavePath

.SentOnBehalfOfName = "[email protected]"

End With

This looks like it is sent from the specified mailbox but in reality it still gets sent from the default account as you will find out as the message is in the default accounts sent item box.
 
Back
Top Bottom