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 -
http://www.thecodecage.com/forumz/o...-outlook-sendusingaccount-change-account.html
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
solution... the closest I came was this thread -
http://www.thecodecage.com/forumz/o...-outlook-sendusingaccount-change-account.html
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