P
p912s
Hello! I have searched all over the web and have been unable to locate a
solution... the closest I came was a thread on here so I joined.
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"
Here is the thread that talked about a solution using a timer to get
the message sent but I don't understand how to implement a timer in
Outlook - http://tinyurl.com/r79d4w
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)
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
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 a thread on here so I joined.
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"
Here is the thread that talked about a solution using a timer to get
the message sent but I don't understand how to implement a timer in
Outlook - http://tinyurl.com/r79d4w
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)
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
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