There are some syntax issues relating to Outlook, so the code should look like the following. Note that the code uses the function from http://www.rondebruin.nl/win/s1/outlook/openclose.htm to open Outlook correctly. You will see why if you read the accompanying data on that linked page. Using the test macro the following works. The code uses late binding to Outlook and does not therefore require a reference to the Outlook object library.
Sub Test()
sendMail "", "This is some text"
End Sub
Public Sub sendMail(Attach As String, txt As String)
'This macro requires
'http://www.rondebruin.nl/win/s1/outlook/openclose.htm
'To open Outlook
Dim appOutLook As Object
Dim MailOutLook As Object
Dim fso As Object
If Attach <> "" Or txt <> "" Then
Set appOutLook = OutlookApp()
Set MailOutLook = appOutLook.CreateItemFromTemplate( _
"C:\Users\ksor\AppData\Roaming\Microsoft\Templates\KS-Mail.oft")
With MailOutLook
.To = ""
.cc = ""
'.bcc = ""
.Subject = "Dokument fra Keld Sørensen"
If txt <> "" Then
.Body = .Body & vbCrLf & vbCrLf & txt
Else
.HTMLBody = "Indtast en besked her !"
End If
If Attach <> "" Then
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(Attach) Then
.Attachments.Add Attach
Else
MsgBox Attach & " eksisterer ikke"
End If
End If
.Display ' Slet ikke denne linje
' .Send ' Her sendes mailen umiddelbart
End With
Else
MsgBox "Du vil ikke skrive tekst, du vil ikke vedhæfte noget !!" & vbCrLf & vbCrLf & _
"Hvad vil du egentlig ... Ret fejlen og prøv igen !"
End If
lbl_Exit:
Set appOutLook = Nothing
Set MailOutLook = Nothing
Set fso = Nothing
Exit Sub
End Sub