Hi All,
I have a VBA script that opens templates from my drafts folder in outlook, I'm struggling to work out how I can get it to get the templates from a file on my C: drive instead of my drafts folder........
this is what I use now within outlook - it works perfectly I just want to be able to change where it gets the template from - thanks in advance!!!
Private Const TemplateFolder As String = "My Templates"
Public Sub Draft_1()
LoadTemplate "New Proposal"
End Sub
Private Sub LoadTemplate(Name As String)
Dim Ns As Outlook.NameSpace
Dim Folder As Outlook.MAPIFolder
Dim Mail As Outlook.MailItem
Set Ns = Application.GetNamespace("MAPI")
Set Folder = Ns.GetDefaultFolder(olFolderDrafts)
Set Folder = Folder.Folders(TemplateFolder)
Set Mail = LoadTemplate_Ex(Folder.Items, Name)
If Not Mail Is Nothing Then
Mail.Display
Else
MsgBox "No template with the subject: '" & Name & "' found"
End If
End Sub
Private Function LoadTemplate_Ex(Items As Outlook.Items, Name As String) As Outlook.MailItem
On Error Resume Next
Dim Mail As Outlook.MailItem
Set Mail = Items.Find("[subject]=" & Chr(34) & Name & Chr(34))
If Not Mail Is Nothing Then
Set LoadTemplate_Ex = Mail.Copy
End If
End Function
I have a VBA script that opens templates from my drafts folder in outlook, I'm struggling to work out how I can get it to get the templates from a file on my C: drive instead of my drafts folder........
this is what I use now within outlook - it works perfectly I just want to be able to change where it gets the template from - thanks in advance!!!
Private Const TemplateFolder As String = "My Templates"
Public Sub Draft_1()
LoadTemplate "New Proposal"
End Sub
Private Sub LoadTemplate(Name As String)
Dim Ns As Outlook.NameSpace
Dim Folder As Outlook.MAPIFolder
Dim Mail As Outlook.MailItem
Set Ns = Application.GetNamespace("MAPI")
Set Folder = Ns.GetDefaultFolder(olFolderDrafts)
Set Folder = Folder.Folders(TemplateFolder)
Set Mail = LoadTemplate_Ex(Folder.Items, Name)
If Not Mail Is Nothing Then
Mail.Display
Else
MsgBox "No template with the subject: '" & Name & "' found"
End If
End Sub
Private Function LoadTemplate_Ex(Items As Outlook.Items, Name As String) As Outlook.MailItem
On Error Resume Next
Dim Mail As Outlook.MailItem
Set Mail = Items.Find("[subject]=" & Chr(34) & Name & Chr(34))
If Not Mail Is Nothing Then
Set LoadTemplate_Ex = Mail.Copy
End If
End Function