Problems reading the subject of a selected MailItem that is beingcreated?

J

Joey

Hello,

I'm having problems retrieving subject line information from a newly
created MailItem that hasn't been saved or sent yet. How does one go
about it? I am using Outlook 2003 and Word's FileDialog (Outlook
doesn't support one).

I tried:

ThisOutlookSession.ActiveInspector.CurrentItem.Subject

to no avail. I can't reference it using the EntryId because it hasn't
been sent or saved -- I'm trying to create my own modified version of
Outlook's Save As so that it will go to a user's specified file location
using the Subject line as the default file name.

Thanks,
Joey.
 
S

Sue Mosher [MVP-Outlook]

The behavior depends on whether WordMail is the editor. Based on your
symptoms, I'd say that it is. Try this approach, which uses the WordMail
window caption as needed:

Function GetCurrentMessageSubject() As String
Dim objItem As Object
Dim objInsp As Outlook.Inspector
Dim objDoc As Word.Document
Dim strSubject As String

Set objInsp = Application.ActiveInspector
If Not objInsp Is Nothing Then
Set objItem = objInsp.CurrentItem
If objItem.Class = olMail Then
If objInsp.EditorType = olEditorWord Then
Set objDoc = objInsp.WordEditor
strSubject = objDoc.ActiveWindow.Caption
strSubject = Replace(strSubject, " - Message", "")
Else
strSubject = Item.Subject
End If
End If
End If
GetCurrentMessageSubject = strSubject

Set objInsp = Nothing
Set objItem = Nothing
Set objDoc = Nothing
End Function
 
Top