Skip to content
This repository has been archived by the owner on Feb 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3 from matteoparlato/working
Browse files Browse the repository at this point in the history
Working
  • Loading branch information
matteoparlato authored Nov 4, 2019
2 parents 2683709 + 6655947 commit 0509b8a
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 27 deletions.
26 changes: 7 additions & 19 deletions OutlookCOMM.COM/MailUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,24 @@

namespace OutlookCOMM.COM
{
[Guid("69C85C8D-DBEB-4d85-83A7-7E5077AD11BA")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IOutlookCOMM
{
/// <summary>
/// Method which creates an EML file with passed information.
/// </summary>
/// <param name="from">The sender address of the mail</param>
/// <param name="to">The receiver address of the mail </param>
/// <param name="subject">The subject of the mail to send</param>
/// <param name="body">The body of the mail to send</param>
/// <param name="attachmentPath">The path of the attachment to add to the mail</param>
/// <param name="unsent">Set the X-Unsent property of the EML</param>
[DispId(1)] bool SaveEML(string from, string to, string cc, string bcc, string subject, string body, string attachmentPath, bool unsent, bool useOutlookAccount);
}

[Guid("0C216A19-E1B7-4b05-86D3-4C516BDDC041")]
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
[Guid("C79C6ABA-10F6-4DEA-B9AE-69DDB62C5881")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("MailUtilities")]
public class MailUtilities:IOutlookCOMM
public class MailUtilities
{
/// <summary>
/// Method which creates an EML file with passed information.
/// </summary>
/// <param name="from">The sender address of the mail</param>
/// <param name="to">The receiver address of the mail </param>
/// <param name="cc">The CC address of the mail</param>
/// <param name="bcc">The BCC address of the mail</param>
/// <param name="subject">The subject of the mail to send</param>
/// <param name="body">The body of the mail to send</param>
/// <param name="attachmentPath">The path of the attachment to add to the mail</param>
/// <param name="unsent">Set the X-Unsent property of the EML</param>
/// <param name="useOutlookAccount">If true uses the sender mail defined in Outlook otherwise uses from parameter</param>
public bool SaveEML(string from, string to, string cc, string bcc, string subject, string body, string attachmentPath, bool unsent, bool useOutlookAccount)
{
string tempFolderPath = Path.Combine(Path.GetTempPath(), "OutlookCOMM");
Expand Down
5 changes: 5 additions & 0 deletions OutlookCOMM.COM/OutlookCOMM.COM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
<Compile Include="MailUtilities.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="RegisterOCOMMInterface.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
58 changes: 58 additions & 0 deletions OutlookCOMM.COM/RegisterOCOMMInterface.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Stop execution when an error occurs
$ErrorActionPreference = "Stop"

# Detect if PowerShell has administrator privileges
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
# Run the script with PowerShell with administrator privileges
$Script = $MyInvocation.MyCommand.Definition
$Ps = Join-Path $PSHome 'powershell.exe'
Start-Process $Ps -Verb runas -ArgumentList "& '$Script'"
exit(0)
}
else
{
# Contains the path of regasm.exe
$RegAsmPath = "$($env:Windir)\Microsoft.NET\Framework\v2.0.50727\regasm.exe"
if (-not (Test-Path $RegAsmPath))
{
throw "regasm.exe not found in $RegAsmPath"
}

# Ask for [Install], [Remove] or [Abort]
$Options = [System.Management.Automation.Host.ChoiceDescription[]] @("&Install", "&Remove", "&Abort")
$Selection = $host.UI.PromptForChoice("Installer of OutlookCOMM for NAV Classic", "What do you want to do?", $Options, 0)
if ($Selection -eq 0 -or $Selection -eq 1)
{
# Create the folder OutlookCOMM in C:\ drive if it does not exists
$TargetFolder = "C:\OutlookCOMM"
if (-not [IO.Directory]::Exists($TargetFolder))
{
[IO.Directory]::CreateDirectory($TargetFolder) | Out-Null
}

# Copy OutlookCOMM files to $TargetFolder
Copy-Item "$PSScriptRoot\OutlookCOMM.COM.dll" -Destination "$TargetFolder" -Force
Copy-Item "$PSScriptRoot\OutlookCOMM.COM.tlb" -Destination "$TargetFolder" -Force

# Create the [Install] command
$RegAsmArgs = ($("`"$TargetFolder\OutlookCOMM.COM.dll`""), "/tlb:`"$("$TargetFolder\OutlookCOMM.COM.tlb")`"", "/silent", "/codebase")

# If user selected [Remove] add /u (unregister) parameter (/unregister is not recognised sometimes)
if ($Selection -eq 1)
{
$RegAsmArgs = @("/u") + $RegAsmArgs

# Detect if finsql.exe is running (can't unregister until closed)
$FinsqlProcess = Get-Process finsql -ErrorAction SilentlyContinue
if($FinsqlProcess)
{
throw "Close all finsql.exe instances before removing OutlookCOMM"
}
}

# Run regasm.exe with passed parameters
& $RegAsmPath @RegAsmArgs
}
exit(0)
}
3 changes: 3 additions & 0 deletions OutlookCOMM.NET/MailUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ public static class MailUtilities
/// </summary>
/// <param name="from">The sender address of the mail</param>
/// <param name="to">The receiver address of the mail </param>
/// <param name="cc">The CC address of the mail</param>
/// <param name="bcc">The BCC address of the mail</param>
/// <param name="subject">The subject of the mail to send</param>
/// <param name="body">The body of the mail to send</param>
/// <param name="attachmentPath">The path of the attachment to add to the mail</param>
/// <param name="unsent">Set the X-Unsent property of the EML</param>
/// <param name="useOutlookAccount">If true uses the sender mail defined in Outlook otherwise uses from parameter</param>
public static bool SaveEML(string from, string to, string cc, string bcc, string subject, string body, string attachmentPath, bool unsent, bool useOutlookAccount)
{
string tempFolderPath = Path.Combine(Path.GetTempPath(), "OutlookCOMM");
Expand Down
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,16 @@ OutlookCOMM is a component which can be used in Microsoft Dynamics NAV as a work
2. Restart NAV service(s).

* For NAV 2013:
1. Copy the OutlookCOMM.NET.dll into the Add-in folder placed inside both NAV service and RTC installation folders (the dll should be copied in every installed RTC - except for ClickOnce installations).
1. Copy the OutlookCOMM.NET.dll into the Add-in folder placed inside both NAV service and RTC installation folders (the dll should be copied in every installed RTC).
2. Restart NAV service(s).

* For NAV 2009R2 (RTC):
1. Copy the OutlookCOMM.NET35.dll into the Add-in folder placed inside both NAV service and RTC installation folders (the dll should be copied in every installed RTC).
2. Restart NAV service(s).

* For NAV 2009R2 Classic and previous versions:
1. Copy the OutlookCOMM.COM.dll into the Add-in folder placed inside NAV Classic installation folder (the dll should be copied in every installed client).
2. From a command prompt with administrator rights run the following commands (on both server and clients):


`cd C:\Windows\Microsoft.NET\Framework\v2.0.50727`

1. Run `RegisterOCOMMInterface.ps1` with PowerShell on every installed client.

`regasm pathOfDllFile /tlb pathOfTlbFile`

### Applying changes to NAV objects

Expand Down

0 comments on commit 0509b8a

Please sign in to comment.