AOB
Registered User.
- Local time
- Today, 15:20
- Joined
- Sep 26, 2012
- Messages
- 621
Hi guys,
Anybody know if it's possible to create a reply to an e-mail if the 'source' e-mail is saved locally as a .msg file (as opposed to using a mailitem directly from an Outlook folder)
Here is as far as I've gotten...
It bombs out on the line in red :
Any suggestions?
Anybody know if it's possible to create a reply to an e-mail if the 'source' e-mail is saved locally as a .msg file (as opposed to using a mailitem directly from an Outlook folder)
Here is as far as I've gotten...
Code:
Private appOutlook As Object [COLOR=darkgreen]' Outlook Application[/COLOR]
Private objNameSpace As Object [COLOR=darkgreen]' Outlook NameSpace[/COLOR]
Private objFolder As Object [COLOR=darkgreen]' Outlook Folder[/COLOR]
Public Sub ReplyToEMail(strSourceEMail As String)
On Error GoTo ErrorHandler
Dim objExplorer As Object
Dim objMailItem As Object
Dim objMailResponse As Object
Set appOutlook = CreateObject("Outlook.Application")
If Not appOutlook.Explorers.Count > 0 Then
[COLOR=darkgreen]' Need to open Outlook 'visibly' for the new MailItem to be retained without error[/COLOR]
Set objNameSpace = appOutlook.GetNamespace("MAPI")
Set objFolder = objNameSpace.GetDefaultFolder(6) [COLOR=darkgreen]' olFolderInbox[/COLOR]
Set objExplorer = appOutlook.Explorers.Add(objFolder, 0) [COLOR=darkgreen]' olFolderDisplayNormal[/COLOR]
With objExplorer
.Activate
.WindowState = 0 [COLOR=darkgreen]' olMaximized
[/COLOR] .WindowState = 1 [COLOR=darkgreen]' olMinimized
[/COLOR]
End With
End If
Set objMailItem = appOutlook.CreateItemFromTemplate(strSourceEMail)
[COLOR=red]Set objMailResponse = objMailItem.Reply[/COLOR]
With objMailResponse
[COLOR=darkgreen]' ....further work to go here...[/COLOR]
(I'm not trying to fire the reply out straight away, merely set up the reply for the user to review and send if appropriate...)Error -2147352567
Could not send the message
Any suggestions?