Attachments are not released until the Microsoft Dynamics NAV client is closed when you use the SMTP Mail codeunit (400) to send email messages that have attachments

Applies to: Dynamics NAV 2009Microsoft Dynamics NAV 5.0

This article applies to Microsoft Dynamics NAV for all countries and all language locales.

Symptoms


When you use the SMTP Mail codeunit (400) to send email messages that have attachments in Microsoft Dynamics NAV 5.0 Service Pack 1 (SP1), the attached files are not released until the Microsoft Dynamics NAV client is closed. Before you close the Microsoft Dynamics NAV client, if you try to delete the attached file, you receive the following error message:

The action can't be completed because the file is open in Microsoft Dynamics NAV Client executable for SQL Server.

You also receive this error message if any errors occur during processing after the file is attached. Therefore, you must close the Microsoft Dynamics NAV client and then you are able to send the email messages.

Note This problem also occurs in the following products:
  • Microsoft Dynamics NAV 2009 Service Pack 1
  • Microsoft Dynamics NAV 2009
  • Microsoft Dynamics NAV 5.0

Cause


This problem occurs because Microsoft .NET Framework waits for the garbage collector to release resources when .NET COM objects are retained in memory.

Resolution


Hotfix information

A supported hotfix is available from Microsoft. There is a "Hotfix download available" section at the top of this Knowledge Base article. If you are encountering an issue downloading, installing this hotfix, or have other technical support questions, contact your partner or, if enrolled in a support plan directly with Microsoft, you can contact technical support for Microsoft Dynamics and create a new support request. To do this, visit the following Microsoft Web site: You can also contact technical support for Microsoft Dynamics by phone using these links for country specific phone numbers. To do this, visit one of the following Microsoft Web sites:

PartnersCustomersIn special cases, charges that are ordinarily incurred for support calls may be canceled if a Technical Support Professional for Microsoft Dynamics and related products determines that a specific update will resolve your problem. The usual support costs will apply to any additional support questions and issues that do not qualify for the specific update in question.




How to obtain the Microsoft Dynamics NAV hotfix or update files

After you request a Microsoft Dynamics NAV hotfix, a hyperlink will be sent to you in an e-mail.


The e-mail will contain a hyperlink and a password. You can use the hyperlink to download the Microsoft Dynamics NAV hotfix or the update files. When you click the hyperlink, the File Download – Security Warning dialog box opens. Then, you are prompted to run, to save, or to cancel the download.


If you click Run, the files start the download and the extraction process. You must specify a folder for the new files, and then provide the password.


If you click Save, you must specify a path for saving the compressed file. When you open the file that you saved, you are prompted to specify a path for the files. Then, you must provide the password provided in the e-mail.


If you click Cancel, the download process stops.



How to install a Microsoft Dynamics NAV hotfix or an update file

The Microsoft Dynamics NAV platform hotfixes and updates are made available as single files. To install a Microsoft Dynamics NAV hotfix or an update, you must replace the existing Microsoft Dynamics NAV installation files with the hotfix or the update files.

File Information

The global version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.
File nameFile versionFile sizeDateTimePlatform
Microsoft.navision.mail.dll7.1.0.026,48007-Jul-201011:20x86
Microsoft.navision.mail.tlbNot applicable3,62007-Jul-201007:57Not applicable
To do this, follow these steps:
  1. Copy the files that you extracted from the hotfix files to the following folder:
    %ProgramFiles%\Common Files\Microsoft Dynamics NAV\Mail
  2. Register the new Microsoft.Navision.Mail.dll assembly through the Assembly Registration tool (Regasm.exe) by using the following command:
    regasm /codebase /tlb:Microsoft.Navision.Mail.tlb Microsoft.Navision.Mail.dll

    For example, you can make sure that the Regasm.exe file is in the Mail folder mentioned in step 1, open the command prompt, change the directory to "C:\Program Files (x86)\Common Files\Microsoft Dynamics NAV\Mail", and then run the following command to register the Microsoft.Navision.Mail.dll assembly:
    RegAsm.exe /codebase /tlb:Microsoft.Navision.Mail.tlb Microsoft.Navision.Mail.dll
  3. In the SMTP Mail Table (409), add the following new field:
    50000 SMTP Server Port, Integer, InitValue=25
  4. In the SMTP Mail Form (409), show the new field 50000 SMTP Server Port on the General tab.
  5. In the SMTP Mail Codeunit (400), change the global variable mail as follows:
    Existing
    'Microsoft Navision Mail'.SmtpMessage
    Replacement
    'Microsoft Dynamics NAV Mail Helper'.SmtpMessage
  6. Change the Send procedure in the SMTP Mail codeunit (400) as follows:
    Existing code
    PROCEDURE Send@3();
    VAR
    Result@1000 : Text[1024];
    BEGIN
    WITH SMTPMailSetup DO
    Result :=
    Mail.Send(
    "SMTP Server",Authentication <> Authentication::Anonymous,"User ID",Password);
    CLEAR(Mail);
    IF Result <> '' THEN
    ERROR(Text003,Result);
    END;
    Replacement code
    PROCEDURE Send@3();
    VAR
    Result@1000 : Text[1024];
    BEGIN
    WITH SMTPMailSetup DO
    Result :=
    Mail.Send(
    "SMTP Server",Authentication <> Authentication::Anonymous,"User ID",Password,"SMTP Server Port");,"SMTP Server Port");

    Mail.Dispose; // Add this line that begians with 10 spaces.

    CLEAR(Mail);

    IF Result <> '' THEN
    ERROR(Text003,Result);
    END;

Prerequisites

You must have Microsoft Dynamics NAV 5.0 Service Pack 1 installed to apply this hotfix.

Note This hotfix also applies to the following products:
  • Microsoft Dynamics NAV 2009 Service Pack 1
  • Microsoft Dynamics NAV 2009
  • Microsoft Dynamics NAV 5.0

To apply this hotfix to these products, you must have one of these products installed.

Removal information

You cannot remove this hotfix.

Status


Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

More Information


For more information, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates

Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.