My attachments lose their original name and are show as ProjectStatus.xlsx












0















In windows 7 and Office 2007 I have been using a code which opens a new email in Outlook, attach a file and send it. The code it's not mine, I found it somewhere in the internet. The problem is that now I use Windows 10 and Office 2016, and using the same code produce different results as:




  • The original name of the file, let's say for example "Products.xlsx", is changed to "ProjectStatus.xlsx" (any file name is always changed to "ProjectStatus.xlsx")

  • If I open the file then Excel opens it and shows the original name of the file ("Products.xlsx")

  • If I send it, sometimes the recipients see the attached file as "ProjectStatus.xlsx" and sometimes see it as "Products.xlsx". But what always happens is that if they open the file, in excel is seen as "Products.xlsx"


I need the file name always be shown with the original name. How can I do this?



This is the code I use it and is executed from both access 2016 and excel 2016.



Sub MandaMailA(destinatarios As String, copia As String, subject As String, strbody As String, attachment1 As String, Optional attachment2 As String = "", Optional CO As String = "")

Dim OutApp As Object
Dim OutMail As Object
Dim SigString As String
Dim Signature As String

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)



'Change only Mysig.htm to the name of your signature
SigString = Environ("appdata") & _
"MicrosoftFirmasVBA.htm"

If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If

On Error Resume Next

With OutMail
.To = destinatarios
.CC = copia
.BCC = CO
.subject = subject
.HTMLBody = strbody & "<br>" & Signature
.Display 'or use .Display
.Attachments.Add attachment1, olByValue, 1, "ProjectStatus"
.Attachments.Add attachment2, olByValue, 1, "ProjectStatus"

End With

On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub


I notice that this code includes the word "ProjectStatus" but honestly I have not a deep knowledge of VBA.



Thanks in advance!!










share|improve this question



























    0















    In windows 7 and Office 2007 I have been using a code which opens a new email in Outlook, attach a file and send it. The code it's not mine, I found it somewhere in the internet. The problem is that now I use Windows 10 and Office 2016, and using the same code produce different results as:




    • The original name of the file, let's say for example "Products.xlsx", is changed to "ProjectStatus.xlsx" (any file name is always changed to "ProjectStatus.xlsx")

    • If I open the file then Excel opens it and shows the original name of the file ("Products.xlsx")

    • If I send it, sometimes the recipients see the attached file as "ProjectStatus.xlsx" and sometimes see it as "Products.xlsx". But what always happens is that if they open the file, in excel is seen as "Products.xlsx"


    I need the file name always be shown with the original name. How can I do this?



    This is the code I use it and is executed from both access 2016 and excel 2016.



    Sub MandaMailA(destinatarios As String, copia As String, subject As String, strbody As String, attachment1 As String, Optional attachment2 As String = "", Optional CO As String = "")

    Dim OutApp As Object
    Dim OutMail As Object
    Dim SigString As String
    Dim Signature As String

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)



    'Change only Mysig.htm to the name of your signature
    SigString = Environ("appdata") & _
    "MicrosoftFirmasVBA.htm"

    If Dir(SigString) <> "" Then
    Signature = GetBoiler(SigString)
    Else
    Signature = ""
    End If

    On Error Resume Next

    With OutMail
    .To = destinatarios
    .CC = copia
    .BCC = CO
    .subject = subject
    .HTMLBody = strbody & "<br>" & Signature
    .Display 'or use .Display
    .Attachments.Add attachment1, olByValue, 1, "ProjectStatus"
    .Attachments.Add attachment2, olByValue, 1, "ProjectStatus"

    End With

    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
    End Sub


    I notice that this code includes the word "ProjectStatus" but honestly I have not a deep knowledge of VBA.



    Thanks in advance!!










    share|improve this question

























      0












      0








      0








      In windows 7 and Office 2007 I have been using a code which opens a new email in Outlook, attach a file and send it. The code it's not mine, I found it somewhere in the internet. The problem is that now I use Windows 10 and Office 2016, and using the same code produce different results as:




      • The original name of the file, let's say for example "Products.xlsx", is changed to "ProjectStatus.xlsx" (any file name is always changed to "ProjectStatus.xlsx")

      • If I open the file then Excel opens it and shows the original name of the file ("Products.xlsx")

      • If I send it, sometimes the recipients see the attached file as "ProjectStatus.xlsx" and sometimes see it as "Products.xlsx". But what always happens is that if they open the file, in excel is seen as "Products.xlsx"


      I need the file name always be shown with the original name. How can I do this?



      This is the code I use it and is executed from both access 2016 and excel 2016.



      Sub MandaMailA(destinatarios As String, copia As String, subject As String, strbody As String, attachment1 As String, Optional attachment2 As String = "", Optional CO As String = "")

      Dim OutApp As Object
      Dim OutMail As Object
      Dim SigString As String
      Dim Signature As String

      Set OutApp = CreateObject("Outlook.Application")
      Set OutMail = OutApp.CreateItem(0)



      'Change only Mysig.htm to the name of your signature
      SigString = Environ("appdata") & _
      "MicrosoftFirmasVBA.htm"

      If Dir(SigString) <> "" Then
      Signature = GetBoiler(SigString)
      Else
      Signature = ""
      End If

      On Error Resume Next

      With OutMail
      .To = destinatarios
      .CC = copia
      .BCC = CO
      .subject = subject
      .HTMLBody = strbody & "<br>" & Signature
      .Display 'or use .Display
      .Attachments.Add attachment1, olByValue, 1, "ProjectStatus"
      .Attachments.Add attachment2, olByValue, 1, "ProjectStatus"

      End With

      On Error GoTo 0
      Set OutMail = Nothing
      Set OutApp = Nothing
      End Sub


      I notice that this code includes the word "ProjectStatus" but honestly I have not a deep knowledge of VBA.



      Thanks in advance!!










      share|improve this question














      In windows 7 and Office 2007 I have been using a code which opens a new email in Outlook, attach a file and send it. The code it's not mine, I found it somewhere in the internet. The problem is that now I use Windows 10 and Office 2016, and using the same code produce different results as:




      • The original name of the file, let's say for example "Products.xlsx", is changed to "ProjectStatus.xlsx" (any file name is always changed to "ProjectStatus.xlsx")

      • If I open the file then Excel opens it and shows the original name of the file ("Products.xlsx")

      • If I send it, sometimes the recipients see the attached file as "ProjectStatus.xlsx" and sometimes see it as "Products.xlsx". But what always happens is that if they open the file, in excel is seen as "Products.xlsx"


      I need the file name always be shown with the original name. How can I do this?



      This is the code I use it and is executed from both access 2016 and excel 2016.



      Sub MandaMailA(destinatarios As String, copia As String, subject As String, strbody As String, attachment1 As String, Optional attachment2 As String = "", Optional CO As String = "")

      Dim OutApp As Object
      Dim OutMail As Object
      Dim SigString As String
      Dim Signature As String

      Set OutApp = CreateObject("Outlook.Application")
      Set OutMail = OutApp.CreateItem(0)



      'Change only Mysig.htm to the name of your signature
      SigString = Environ("appdata") & _
      "MicrosoftFirmasVBA.htm"

      If Dir(SigString) <> "" Then
      Signature = GetBoiler(SigString)
      Else
      Signature = ""
      End If

      On Error Resume Next

      With OutMail
      .To = destinatarios
      .CC = copia
      .BCC = CO
      .subject = subject
      .HTMLBody = strbody & "<br>" & Signature
      .Display 'or use .Display
      .Attachments.Add attachment1, olByValue, 1, "ProjectStatus"
      .Attachments.Add attachment2, olByValue, 1, "ProjectStatus"

      End With

      On Error GoTo 0
      Set OutMail = Nothing
      Set OutApp = Nothing
      End Sub


      I notice that this code includes the word "ProjectStatus" but honestly I have not a deep knowledge of VBA.



      Thanks in advance!!







      vba excel-2016 ms-access-2016 outlook-2016






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 15 '18 at 9:45









      Dani LADani LA

      455




      455
























          1 Answer
          1






          active

          oldest

          votes


















          1














          A simple read of the Attachments.Add documentation is all you need, specifically the section on the optional DisplayName parameter:




          This parameter applies only if the mail item is in Rich Text format
          and Type is set to olByValue : the name is displayed in an Inspector
          object for the attachment or when viewing the properties of the
          attachment. If the mail item is in Plain Text or HTML format, then the
          attachment is displayed using the file name in the Source parameter.




          So if you always want to always use the original file name, simply delete the instances of , "ProjectStatus".






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53316535%2fmy-attachments-lose-their-original-name-and-are-show-as-projectstatus-xlsx%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            A simple read of the Attachments.Add documentation is all you need, specifically the section on the optional DisplayName parameter:




            This parameter applies only if the mail item is in Rich Text format
            and Type is set to olByValue : the name is displayed in an Inspector
            object for the attachment or when viewing the properties of the
            attachment. If the mail item is in Plain Text or HTML format, then the
            attachment is displayed using the file name in the Source parameter.




            So if you always want to always use the original file name, simply delete the instances of , "ProjectStatus".






            share|improve this answer




























              1














              A simple read of the Attachments.Add documentation is all you need, specifically the section on the optional DisplayName parameter:




              This parameter applies only if the mail item is in Rich Text format
              and Type is set to olByValue : the name is displayed in an Inspector
              object for the attachment or when viewing the properties of the
              attachment. If the mail item is in Plain Text or HTML format, then the
              attachment is displayed using the file name in the Source parameter.




              So if you always want to always use the original file name, simply delete the instances of , "ProjectStatus".






              share|improve this answer


























                1












                1








                1







                A simple read of the Attachments.Add documentation is all you need, specifically the section on the optional DisplayName parameter:




                This parameter applies only if the mail item is in Rich Text format
                and Type is set to olByValue : the name is displayed in an Inspector
                object for the attachment or when viewing the properties of the
                attachment. If the mail item is in Plain Text or HTML format, then the
                attachment is displayed using the file name in the Source parameter.




                So if you always want to always use the original file name, simply delete the instances of , "ProjectStatus".






                share|improve this answer













                A simple read of the Attachments.Add documentation is all you need, specifically the section on the optional DisplayName parameter:




                This parameter applies only if the mail item is in Rich Text format
                and Type is set to olByValue : the name is displayed in an Inspector
                object for the attachment or when viewing the properties of the
                attachment. If the mail item is in Plain Text or HTML format, then the
                attachment is displayed using the file name in the Source parameter.




                So if you always want to always use the original file name, simply delete the instances of , "ProjectStatus".







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 15 '18 at 10:01









                BigBenBigBen

                6,3652618




                6,3652618
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53316535%2fmy-attachments-lose-their-original-name-and-are-show-as-projectstatus-xlsx%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Xamarin.iOS Cant Deploy on Iphone

                    Glorious Revolution

                    Dulmage-Mendelsohn matrix decomposition in Python