Skip to main content

Users receive an error when trying to Send via Email from Document Revision. Error: Got an error when trying to send the e-mail using Outlook. Error number: -2147392967 Array index out of bounds.Microsoft Outlook. Generally, when the user tries again, it works. Won"t spin up an email to email the attachment, and Kim can"t use the Edit Document function to pull up the documents to edit either.

Review with IFS team included:

* Ambers computer: Aurena Agent: 1.5.3 Version 0.6 and was last installed on 5/16/23
* Error Message seen still (Error Message: “Got an error when trying to send the e-mail using Outlook. Error Number: -2147352567 Array index out of bounds.Microsoft.Outlook”)
* File>>Manage COM Add-ins>>IFS Document Management Addin>>Always enable this addin & always monitor>>Apply and then restart Outlook.
* Document Management>>Document Revision>>AP456>>Share/Distribute>>Send Document File by Email. Same error seen. Document is Excel Document.
* Tried with basic text document. Drawing Approval Test, AP456. Same error seen

Hi,

Do you know if you have any document macro installed for sending e-mails? If not, I think you should report this to IFS support.
 


We do have document macros installed.

We have also tried the macros we were provided by IFS as well as one we seen that another post had in it. Neither have worked.

We input an IFS ticket a while back but they seem to be stumped as well.


Ah, yes, I remember we (R&D) got a question about this some time ago, from global support.

Can you post the macro code here and the exact steps needed to test it? What document class was used, what title, what kind of file was attached, how big, etc.?


Macro below (we have attempted with and without ‘Fix up slashes and backslashes)

 

Public Sub CreateNewOutlookMail

 

   On Error Resume Next

 

   Dim ol, newMail, olMailItem, file, path

 

   olMailItem = 0

   Set ol = CreateObject("Outlook.Application")

 

   Set newMail = ol.CreateItem(olMailItem)

 

   newMail.Subject = "Regarding document " & ScriptValues.Item("DOCUMENT_TITLE").Value

 

   newMail.Body = "This is the message body. We can insert whatever blurb we choose here.  Contact Samuel IT to adjust." & vbCrLf

 

   ' Fix up slashes and backslashes

 

   path = Replace(Replace(ClientScriptValues.Item("CHECK_OUT_PATH").Value, "/", "\"), "\\", "\")

 

   ' Add a backslash at the end of the path if it is not there

 

   If Not Mid (path, Len (path)) = "\" Then

    path = path & "\"

   End If

 

   file = path & "temp\" & ClientScriptValues.Item("LOCAL_FILE_1").Value

 

   newMail.Attachments.Add (file)

 

   newMail.Display

 

   Set ol = Nothing

 

   If Err.Number <> 0 Then

      MsgBox "Got an error when trying to send the e-mail using Outlook. Error number: " & CStr(Err.Number) & " " & Err.Description & Err.Source

      Err.Clear

   End If

 

End Sub

 

___________________________________________________________________________________________________

Testing:

 

Doc Class = AP457

Document Revision – (use checked in document) – Share/Distribute – Send document file by email

 

File type = .xlsx

File sizes can vary but most that have been tested are 38 KB

 

 


The below works for me. 23R1 though.

Public Sub Gurka

   On Error Resume Next

   Dim ol, newMail, olMailItem, file, path

   

   olMailItem = 0

   Set ol = CreateObject("Outlook.Application")

   Set newMail = ol.CreateItem(olMailItem)

   newMail.Subject = "Regarding document " & ScriptValues.Item("DOCUMENT_TITLE").Value

   newMail.Body = "This is the message body. We can insert whatever blurb we choose here.  Contact Samuel IT to adjust." & vbCrLf

   ' Fix up slashes and backslashes

   path = Replace(Replace(ClientScriptValues.Item("CHECK_OUT_PATH").Value, "/", "\"), "\\", "\")

   

   MsgBox "Check out path = " & path

   ' Add a backslash at the end of the path if it is not there

   If Not Mid (path, Len (path)) = "\" Then

    path = path & "\"

   End If

   

   file = path & "temp\" & ClientScriptValues.Item("LOCAL_FILE_1").Value

   

   MsgBox "file to attach = " & file

   newMail.Attachments.Add (file)

   newMail.Display

   Set ol = Nothing

   

   If Err.Number <> 0 Then

      MsgBox "Got an error when trying to send the e-mail using Outlook. Error number and description: " & CStr(Err.Number) & " " & Err.Description & Err.Source

      Err.Clear

   End If

   

End Sub

 

Try it and see. If it works, you might want to comment out the message boxes :)

 


We have tried the above macro but it does not seem to work with 22R1.

 

My IT guru tried the macro you provided and stated that it just spins on the Share/Distribute email.  No document shows in in his C:\temp folder (where we have it going to currently.)This is what it was doing when the IFS extension was not installed, and he did verify it is installed correctly.

 

Do you have any other ideas/solutions that we could try?


If you replace the body of the macro with just a message box, does it appear then?


No, the Share/Distribute box is only spinning and nothing appears, then stops spinning.


Hi again, sorry for the late reply. I've been on vacation…

Can you share the "message box macro with us" here? It's easy to do mistakes when writing these macros. I did it myself the other day, it was an innocent misspelled word which made the macro stop working.


Thank you for your response! I hope your vacation was wonderful :)

 

We currently have two different Document Macro Blocks set up….

The first one SPVG_OUTLOOK is my test location for recommended changes offered.  Currently this is just a message box.

The second one OUTLOOK is written as below.

 

Public Sub CreateNewOutlookMail

 

   On Error Resume Next

 

   Dim ol, newMail, olMailItem, file

 

   olMailItem = 0

   Set ol = CreateObject("Outlook.Application")

 

   Set newMail = ol.CreateItem(olMailItem)

 

   newMail.Subject = "Regarding " & ScriptValues.Item("DOCUMENT_TITLE").Value

 

   newMail.Body = "This is the message body..."

 

   file = Replace(Replace(ClientScriptValues.Item("CHECK_OUT_PATH").Value, "/", "\"), "\\", "\") & "temp\" & ClientScriptValues.Item("LOCAL_FILE_1").Value

 

   newMail.Attachments.Add (file)

 

   newMail.Display

  

   Set ol = Nothing

 

   If Err.Number <> 0 Then

      MsgBox "Got an error when trying to send the e-mail using Outlook. Error number: " & CStr(Err.Number) & " " & Err.Description & Err.Source

      Err.Clear

   End If

  

End Sub


You wrote:

> Currently this is just a message box.

Is it really just a message box in the code? Can you post the full macro block please? It's very easy to miss a single character and the macro will fail to run.

 


I sent the code on the last email for the Macro Block called “OUTLOOK”.  The SPVG_OUTLOOK one, I just left a message box in there to see if I would even get a message, which I did not.  That is the one where I used the code “PUBLIC SUB Gupta”that was in the post.


I looked above and I cannot find the example that only shows a message box (sorry if I'm misunderstanding you).

Can you share the content of that macro block? As mentioned, it's very easy to make a small mistake.

The reason I am asking about this is that we need to understand if you have a general problems running macros, e.g. they are not running at all, or if there are details in a specific macro that causes the problem. If it's the latter, we can often find the place that fails by adding more message boxes, running the macro and then observing what messages are seen and what messages are not seen.


Please see my IT person’s response below:

Someone has deleted the Document Macro Block “Outlook”.  “SPVG_OUTLOOK” still exists.  I entered the below macro and I am now getting error messages again on array.  Unfortunately, now after I clear the error, the error returns immediately and does not open Outlook to send an email.

 

I would like to delete the macro and start over again but I receive this error message.  I am thinking this may be the problem with updating these macros and why they do not work.  Would you mind sharing this information in the community post?

 

 

 

 

Public Sub CreateNewOutlookMail

 

   On Error Resume Next

 

   Dim ol, newMail, olMailItem, file

 

   olMailItem = 0

   Set ol = CreateObject("Outlook.Application")

 

   Set newMail = ol.CreateItem(olMailItem)

 

   newMail.Subject = "Regarding " & ScriptValues.Item("DOCUMENT_TITLE").Value

 

   newMail.Body = "This is the message body..."

 

   file = Replace(Replace(ClientScriptValues.Item("CHECK_OUT_PATH").Value, "/", "\"), "\\", "\") & "temp\" & ClientScriptValues.Item("LOCAL_FILE_1").Value

 

   newMail.Attachments.Add (file)

 

   newMail.Display

  

   Set ol = Nothing

 

   If Err.Number <> 0 Then

      MsgBox "Got an error when trying to send the e-mail using Outlook. Error number: " & CStr(Err.Number) & " " & Err.Description & Err.Source

      Err.Clear

   End If

  

End Sub


Hi @SILSCONNOR 

I finally got time to try this myself in 22R1 and I get the same error as you do. It works for me the second time I try though, and I think I know why: the macro runs before the file has been downloaded. This is a bug. The second time we try, the file is already there (from the last time we tried), and then the macro can create an e-mail and attach the file.

I think this might have been fixed on your version, but I'm not sure, so you should report it. It seems to be fixed in 23R1 as it worked when I tested there.

Until this is fixed you can inform the users that uses the send by e-mail command to ignore the error and try again. Or you can silence the error and show a message box to try again. I have adjusted the macro to do this:

Public Sub SendMail

   On Error Resume Next

   Dim ol, newMail, olMailItem, file, path

   olMailItem = 0

   Set ol = CreateObject("Outlook.Application")

   Set newMail = ol.CreateItem(olMailItem)

   newMail.Subject = "Regarding document " & ScriptValues.Item("DOCUMENT_TITLE").Value

   newMail.Body = "This is the message body. We can insert whatever blurb we choose here.  Contact Samuel IT to adjust." & vbCrLf

   ' Fix up slashes and backslashes

   path = Replace(Replace(ClientScriptValues.Item("CHECK_OUT_PATH").Value, "/", "\"), "\\", "\")

   'MsgBox "Check out path = " & path

   ' Add a backslash at the end of the path if it is not there

   If Not Mid (path, Len (path)) = "\" Then

    path = path & "\"

   End If

   file = path & "temp\" & ClientScriptValues.Item("LOCAL_FILE_1").Value

   'MsgBox "file to attach = " & file

   newMail.Attachments.Add (file)

   newMail.Display

   Set ol = Nothing

   If Err.Number <> 0 Then

      If InStr(Err.Description, "Array index out of bounds") > 0 Then

         MsgBox "The file was not downloaded yet and cannot be attached. Click OK and try to send the document again."

      Else

         MsgBox "Got an unexpected error when trying to send the e-mail using Outlook. Error number and description: " & CStr(Err.Number) & " " & Err.Description & Err.Source

      End If

      Err.Clear

   End If

End Sub

In theory it might be possible to tweak the macro to, in some way, open Outlook after a delay, such that the file has been downloaded. But that's a bit unreliable since it takes a different length of time depending on the size. I hope the macro above can work for you until you get the bug fixed.

Good luck!

 


Good Morning,

 

I provided the above to our IT department and they stated that “I tested this new macro. It gives the correct message as if it is about to send then does nothing. It does work on the second try. I assume that conflict with Outlook timing is the issue here.”


@SILSCONNOR 

Hi, thanks for reporting back.

If they refer to this message, then nothing should happen:

"The file was not downloaded yet and cannot be attached. Click OK and try to send the document again."

Is that the message they refer to?

Also, as mentioned above, please report this "timing problem" such that we can look into and fix it. Until it has been fixed, your users need to live with this annoyance.
 


Reply