Replying code not working

J

John

Hi

I have the below code to reply to an email with a standard template. The
problem is that it is not working on outlook xp which is connected to an
exchange 2003. Basically nothing happens on these three lines;

Set Item = objApp.CreateItemFromTemplate("f:\EspritStaff.oft")
Item.To = objItem.SenderEmailAddress
Item.Display (False)

I have run this code on a standalone outlook 2003 and it works fine. What is
wrong and how can I fix it?

Thanks

Regards



Sub ReplySpecial()
Dim objApp As Application
Dim objSel As Selection
Dim objItem As Object
Dim Item As MailItem

Set objApp = CreateObject("Outlook.Application")
Select Case objApp.ActiveWindow.Class
Case olExplorer
Set objSel = objApp.ActiveExplorer.Selection
If objSel.Count > 0 Then
Set objItem = objSel.Item(1)
End If
Case olInspector
Set objItem = objApp.ActiveInspector.CurrentItem
Case Else
' can't handle any other kind of window
End Select

If objItem.Class = olMail Then
' MsgBox objItem.SenderEmailAddress
Set Item = objApp.CreateItemFromTemplate("c:\Esprit Staff
Information.oft")
Item.To = objItem.SenderEmailAddress
Item.Display (False)
Else
MsgBox "This is not an email. Please select an email.", vbInformation
+ vbOKOnly, "Reply"
End If

Set objItem = Nothing
Set objSel = Nothing
Set objApp = Nothing
End Sub
 
S

Sue Mosher [MVP-Outlook]

Where are you running this code? In Outlook VBA? Did you check your macro security settings?
 
J

John

Yes in outlook project. Macro settings are set to low.

Regards

Where are you running this code? In Outlook VBA? Did you check your macro
security settings?
 
J

John

PS: I have traced the code and the program just ends after executing this
line; Item.To = objItem.SenderEmailAddress. There is no error message but
the yellow highlight that shows the current statement in trace just
disappears. Is there another way to get the sender's email address from an
email object?

Regards


Where are you running this code? In Outlook VBA? Did you check your macro
security settings?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top