![]() |
Why is OL not keeping the correct sender account?
Hello,
I like to manipulate a mail before sending. But after modifying (subject, message, attachments), the e-mail gets allways sent using the default account and not using the selected account (VB6 COM AddIn using Redemption Objects): To trace the problem I made a little routine to find out which sender currently is selected for a given Mailobject: Public Function GetMailSenderAccountName(ByRef Mailobject As Object) Dim RDOSession As Redemption.RDOSession Dim RDOMessage As Redemption.RDOMail Mailobject.Save ' needed to get an EntryID Set RDOSession = CreateObject("Redemption.RDOSession") RDOSession.MAPIOBJECT = Application.Session.MAPIOBJECT Set RDOMessage = RDOSession.GetMessageFromID(Mailobject.EntryID) GetMailSenderAccountName = RDOMessage.Account.Name End Function Using the following code, I get allways the correct account: Set MyItem = ConnectClass.VBInstance.Session.GetItemFromID(Item ID) Debug.Print "Before sending: " & GetMailSenderAccountName(MyItem) - "smtp.correct.com" RedemptionMail.Item = MyItem ' use redemption objects here (needed?) RedemptionMail.Send Debug.Print "After sending: " & GetMailSenderAccountName(MyItem) - "smtp.correct.com" But the mail has been sent using the wrong account (default account). The "smtp.correct.com" account is working great, if I do not use the methods above. Same problem using OL2003 and OL2007. What can I do to keep the selected account for sending? Thank you, Kukulkan |
Why is OL not keeping the correct sender account?
Hello,
I found a solution to this problem. I simply needed to set the Account again to let Outlook do what I want. The following way helped me out: Public Function SendUsingRDO(ByRef Mailobject As Object) Dim RDOSession As Redemption.RDOSession Dim RDOMessage As Redemption.RDOMail Dim RDOAccount As Redemption.RDOAccount ' save the mail, in case it is not saved until now Mailobject.Save Set RDOSession = CreateObject("Redemption.RDOSession") RDOSession.MAPIOBJECT = Application.Session.MAPIOBJECT Set RDOMessage = RDOSession.GetMessageFromID(Mailobject.EntryID) Set RDOAccount = RDOMessage.Account ' get account If Not RDOAccount Is Nothing Then ' set the account again RDOMessage.Account = RDOSession.Accounts(RDOAccount.Name) RDOMessage.Save End If RDOMessage.Send SendUsingRDO = True End Function At first I read the Account that is used (reading). Upon this, I set this value again (writing). Now calling the .Send method forces Outlook to use the account that has been set but ignored. Strange... Kukulkan |
All times are GMT +1. The time now is 12:28 PM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com