<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<!--Created: 12.02.2010 17:36:41-->
<!--ACTOptimumVersion: 4.1.3687.35011-->
<AutoDataItems ACTOptimumVersion="4.1.3687.35011" Created="12.02.2010 17:36:41">
    <AutoDataControl Created="12.02.2010 17:36:41" ClassName="Melville_Schellmann.ACTOptimum3.Control.AutoData3.AutoData3" PrefClassVersion="1.0" ACTOptimumVersion="4.1.3687.35011">
        <Source>      Dim sDoc As String

      sDoc = "letter.adt" 'Name der Vorlgendatei im Ordner "Templates"


	' Funktion: Aus einer Vorlagen-Datei eine E-Mail an den aktuellen Kontakt erstellen.
	' Autor: Robert Schellmann, rs@melville-schellmann.de
	' Datum: 12.02.2010

      Dim sPath As String
      Dim sScriptName As String

      sScriptName = "Erstelle E-Mail aus Vorlage"
      sPath = ACTApp.ActFramework.SupplementalFileManager.Workgroup.Path &amp; "\Templates" &amp; "\" &amp; sDoc
      If Not System.IO.File.Exists(sPath) Then
         MsgBox(String.Format("Es konnte nicht die Vorlage '{0}' gefunden werden.", sPath), MsgBoxStyle.Information, sScriptName)
         GoTo Abbruch
      End If

      ' Reflection-Aufruf von ACTApp.Explorer.CustomCommandHelper.CustomCommandHandler(sPath)

      Dim oMailMerge As Act.UI.Correspondence.EmailMailMergeInfo
      Dim oSelectedContact As Act.Framework.Contacts.ContactList
      Dim oWordProcessor As Object

      Dim oProperty As System.Reflection.PropertyInfo
      Dim sProperty As String
      Dim oMethod As System.Reflection.MethodInfo
      Dim sMethod As String
      Dim aParameter(0) As Object

      oMailMerge = New Act.UI.Correspondence.EmailMailMergeInfo
      oSelectedContact = ACTApp.ActFramework.Contacts.GetContactAsContactList(ACTApp.ApplicationState.CurrentContact)
      If oSelectedContact.Count = 0 Then
         MsgBox("Es ist kein Kontakt vorhanden.", MsgBoxStyle.Information, sScriptName)
      End If
      With oMailMerge
         'Nur ab ACT! 11
         '.EmailCreateHistoryType = Act.Framework.Preferences.Enums.EmailCreateHistoryType.AttachContact
         .ReturnReciept = False
         .MergeContacts = oSelectedContact
         .TemplateType = Act.UI.Correspondence.PredefinedWordProcessorFilesTypes.Other
         .MergeTemplate = sPath
      End With

      sProperty = "CurrentWordProcessorManager"
      oProperty = ACTApp.UICorrespondenceManager.GetType.GetProperty(sProperty, Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic)


      If oProperty Is Nothing Then
         MsgBox(String.Format("Die Eigenschaft '{0}' wurde nicht gefunden.", sProperty), MsgBoxStyle.Exclamation, sScriptName)
         GoTo Abbruch
      End If
      oWordProcessor = oProperty.GetValue(ACTApp.UICorrespondenceManager, Nothing)

      sMethod = "CreateMergeDocument"
      oMethod = oWordProcessor.GetType.GetMethod(sMethod, Reflection.BindingFlags.Instance Or Reflection.BindingFlags.Public)
      If oMethod Is Nothing Then
         MsgBox(String.Format("Die Methode '{0}' wurde nicht gefunden.", sMethod), MsgBoxStyle.Exclamation, sScriptName)
         GoTo Abbruch
      End If
      aParameter(0) = oMailMerge
      Try
         oMethod.Invoke(oWordProcessor, aParameter)
      Catch ex As Exception
         MsgBox(String.Format("Es ist ein Fehler beim Ausführen der Methode '{0}' aufgetreten.", sMethod) &amp; vbCrLf &amp; _
                ex.Message, MsgBoxStyle.Exclamation, sScriptName)
      End Try
Abbruch:
      Return String.Empty</Source>
        <SourceComment>Begriff: {0}</SourceComment>
        <TargetFields></TargetFields>
        <MsgText>{0}</MsgText>
        <Picklist></Picklist>
        <Multiple>False</Multiple>
        <Expandable>True</Expandable>
        <OverwriteAlways>True</OverwriteAlways>
        <CopyToClipboard>False</CopyToClipboard>
        <ShowMsgBox>False</ShowMsgBox>
        <PositionMode>1</PositionMode>
        <FlatStyle>Standard</FlatStyle>
        <AutoDataText>E-Mail (Brief)</AutoDataText>
        <TextAlign>MiddleCenter</TextAlign>
        <AutoDataFormSize>160; 270</AutoDataFormSize>
        <TooltipText></TooltipText>
        <RefreshLoadedViews>False</RefreshLoadedViews>
    </AutoDataControl>
</AutoDataItems>