Send Email - Exchange Shared Mailbox

racer25

Slowly Getting There
Local time
Today, 23:19
Joined
May 30, 2005
Messages
65
Hi All,

Historically we were able to send an email using multiple accounts in Outlook and I have the VBA below that would pick the account to send the email from.

Code:
.SendUsingAccount = OutApp.Session.Accounts.Item(1)

We have now moved to an Exchange Environment and I have 1 Account, but within that 1 account I have my own email, and access to 2 shared email accounts. I wish to send email from one of the shared email accounts, further all the sent emails must be in this shared mailbox.

I have done my googling and can find pointers, but nothing that worked (wrong solution or me ).

http://www.codeforexcelandoutlook.com/blog/2009/01/handling-multiple-inboxes/

I found this but didn't get close.

Thanks

Rob
 
Thanks for reading - however the solution is one that I had working which assumes I have multiple accounts.

In Exchange, I have only 1 account and I think 'namespace' gets involved.....
 
Okaaay, my stuff runs without Exchange.

Time to bring on some Exchange experts ... or perhaps look or ask at http://outlookcode.com/ , where I also picked up a number of useful tips.
 
We have now moved to an Exchange Environment and I have 1 Account, but within that 1 account I have my own email, and access to 2 shared email accounts. I wish to send email from one of the shared email accounts,

see here for the method you need to use http://msdn.microsoft.com/en-us/library/aa220116(office.11).aspx I never really understand MSDN stuff so here is my example as well NOTE this is for olFolderCalendar which you have to change for inbox.

Code:
Dim objApp As Outlook.Application
Dim objNS As Outlook.Namespace
Dim objFolder As Outlook.MAPIFolder 'get name of other persons folder
Dim objRecip As Outlook.Recipient 'other persons name
Dim strName As String 'the name or email of the persons folder

On Error Resume Next 'will skip over errors


' ### email address of the Calendar/email etc you want to use ###
strName = str_app_user

Set objNS = objApp.GetNamespace("MAPI")

Set objRecip = objNS.CreateRecipient(strName)

'objRecip.Resolve  ' you can use this if your exchange server is slow at getting information

'If objRecip Is Nothing Then
'    CheckForDelegate = False
'End If


Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)

If objFolder Is Nothing Then
    MsgBox "Most likely you are not allowed to send emails from this account"
End If

'Otherwise from this folder you can now make a new email, add contents and send.


Set objNS = Nothing
Set objFolder = Nothing
Set objRecip = Nothing

Set objApp = Nothing
further all the sent emails must be in this shared mailbox.
I am still on Outlook 2003 but from what I understand you have a profile and this is set up with your main email address. Then you have added other shared email addresses to it. If you send an email from a shared email address you will see that it always goes into the SENT ITEMS of your main email address. The only way to changes this is with VBA code which listens to emails being send and moves them to the shared email addresses "SENT ITEMS" after it has been sent.
 
Thanks a million - spent too much time on this today so will have a 'play' tomorrow.
 

Users who are viewing this thread

Back
Top Bottom