SendUsingAccount to change from account

Status
Not open for further replies.
P

p912s

Hello! I have searched all over the web and have been unable to locate a

solution... the closest I came was this thread -

My problem is sending a message after changing the sending account in VBA. I

get an error - "You Cannot Send An Item That Is Already In The Process Of

Being Sent"

And here is my code - fairly simple, it gathers up the pop3 accounts and

presents them in a popup message to select the account to send from. The

selecting and changing accounts works fine but the messages can't be sent. I

have documented in the code where the error happens.

Thanks.

Option Explicit

Private Sub Application_ItemSend(ByVal item As Object, Cancel As Boolean)

Exit Sub

Dim oAccount As Outlook.Account

Dim strDefaultAccount As String, strMsg As String, strID As String

Dim strAccounts(100)

Dim c As Integer, i As Integer

Dim result As Variant

c = 1

'get default account

strDefaultAccount = Application.Session.Accounts(1).DisplayName

'get pop3 accounts

For Each oAccount In Application.Session.Accounts

If oAccount.AccountType = olPop3 Then

strAccounts(c) = c & " - " & oAccount

'Debug.Print strAccounts(c)

c = c + 1

End If

Next

'build inputbox account list

strMsg = "Click Ok to use default account or enter the number of the

account to use...." & vbCrLf

For i = 1 To c

strMsg = strMsg & vbCrLf & strAccounts(i)

Next i

'********************************************************

'message id

'I think this is the id i need to recall and send the message?

strID = item.ConversationIndex

'********************************************************

'display inputbox

result = InputBox(strMsg, "Select Sending Account", strDefaultAccount)

'act on user input

Select Case result

Case strDefaultAccount

'clicked ok - send from default account

Cancel = True

Set item.SendUsingAccount = Application.Session.Accounts(1)

'********************************************************

'send error - "You Cannot Send An Item That Is Already In The

Process Of Being Sent"

item.Send

'********************************************************

Case IsNumeric(result)

'typed a number - send from account entered

If result <= i Then

Cancel = True

Set item.SendUsingAccount =

Application.Session.Accounts(result)

'********************************************************

'send error - "You Cannot Send An Item That Is Already In

The Process Of Being Sent"

item.Send

'********************************************************

Else

'entered incorrect number - stay in message

Cancel = True

End If

Case Else

'clicked cancel or invalid entry - stay in message

Cancel = True

End Select

End Sub
 
D

Dmitry Streblechenko

Try to cancel the submission by setting theancel parameter to true, then

re-submit the message after setting the SendUsingAccount property.

Dmitry Streblechenko (MVP)
 
P

p912s

Isn't that what I have done here? I'm canceling, setting the account

and then trying to send.
 
D

Dmitry Streblechenko

You need to resubmit the message when you are out of the ItemSend event

handler. You can use a timer for that.

Dmitry Streblechenko (MVP)
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P Outlook SendUsingAccount to change from account Outlook VBA and Custom Forms 5
S Macro using .SendUsingAccount only works the first time, after starting Outlook Outlook VBA and Custom Forms 4
S Unable to change Message Class Outlook VBA and Custom Forms 0
S New Outlook Appointment - Select All Body Text and Change Font and Size Outlook VBA and Custom Forms 1
J VBA Cannot programmatically input or change Value for User Defined field Using Outlook 1
C Outlook 365 Can you change the follow up colour? Using Outlook 1
A Change settings Send/receive VBA Outlook VBA and Custom Forms 0
E Outlook VBA change GetDefaultFolder dynamically Outlook VBA and Custom Forms 6
O What would be the recommended way to change an email address (family member)? Using Outlook 0
S Change "This Week" flag start date behavior Using Outlook 1
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
D Change Microsoft Account password - what to do to update on all devices Using Outlook 4
S Outlook 2016 Change how Outlook shows me contacts in emails Using Outlook 0
witzker HowTo Change message Class of contact form Outlook VBA and Custom Forms 0
Z Outlook 365 delete reminder you can’t make change to contents of this-read only folder Using Outlook 4
witzker Pls help to change the code for inserting date in Ol contact body Outlook VBA and Custom Forms 5
R How to Change Margins In Google Docs...? Using Outlook 0
e_a_g_l_e_p_i Outlook 2010 How can I change the font size on right side appointment pane Using Outlook 12
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
B Change Font and Font size using VBA Outlook VBA and Custom Forms 9
D Change senders title Using Outlook 1
W Recurrence: delete older occurrences / change earliest start time Outlook VBA and Custom Forms 0
E Change sending account depending on Subjectline Outlook VBA and Custom Forms 0
J Outlook 2013 Change color of text in data fields of contacts in Outlook 2013? Using Outlook 10
B Change row background color of selected item Using Outlook 1
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0
B Change from Address Outlook VBA and Custom Forms 0
X If you change expiration date of repeated task it dupplicates Using Outlook 1
E How to display "Change Folder" in Change Default Email Delivery Location in Exchange Outlook 2016 Using Outlook 1
Z See "Change View" Drop Down as a List? Using Outlook 1
V Change start time based on message duration Outlook VBA and Custom Forms 2
R Folder pane width change Using Outlook 88
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
S Outlook 2010 unable to change default font Using Outlook 7
P How can I change my calendar view back Using Outlook 3
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
T Change the selected Message in the Outlook window Outlook VBA and Custom Forms 2
geofferyh How to change the Attachment File Name? Outlook VBA and Custom Forms 1
W Appointment occurrences change the location property Using Outlook 0
T Scheduled footer change Using Outlook 2
B Change font of reminder of an email header Outlook VBA and Custom Forms 3
CWM030 Name Change? Exchange Server Administration 9
V not able to change name in customize Ribbon Outlook VBA and Custom Forms 1
JoeG Appointment Delete/Change Recurrence Outlook VBA and Custom Forms 0
C Change Subject Line in Selected Emails Outlook VBA and Custom Forms 1
V Change default default save location to Quick Access Using Outlook 1
C Change default "Save Sent Item To" folder Outlook VBA and Custom Forms 9
S Example VBA Macro - To Conditionally Change the From Account and Add a BCC Address on Emails Outlook VBA and Custom Forms 11
B Do not change the From address in Outlook Templates Using Outlook 0
M Sudden change in From field - now very short Using Outlook 4

Similar threads

Top