Macro - Insert attachment name in mail body

  • Thread starter Thread starter -=KoolPal=-
  • Start date Start date
K

-=KoolPal=-

I had this macro earlier, but its lost due a PC crash.

The requirement is as follows:

1. I write an email.
2. I insert an attachment manually (abc.doc).
3. I run macro and it writes (See atatchment abc.doc) at cursor.
4. I am free to send mail / save as draft.

The version I had seen had an option to retain the mail in an HTML
format or convert mail to text.

I would really appreciate if anyone could point me to the newsgroup
posting which had this code.

TIA

-=KoolPal=-
 
ok, folks, I did some jugglery and managed to get the earlier macros
from my crashed data...here it is for those who need it.

This needs to go into a Module in outlook vba

Public Function GetCurrentItem() As Object
On Error Resume Next
If TypeName(Application.ActiveWindow) = "Explorer" Then
Set GetCurrentItem = ActiveExplorer.Selection(1)
Else
Set GetCurrentItem = ActiveInspector.CurrentItem
End If
End Function
Sub AttNames()
Dim itmMessage As MailItem
Dim strAttNames As String
Dim intC As Integer

On Error Resume Next
Set itmMessage = GetCurrentItem

If Not itmMessage Is Nothing Then
With itmMessage
If .Attachments.Count And _
..GetInspector.EditorType = olEditorHTML Then
'Change olEditorHTML to olEditorText to make this work in text format
For intC = 1 To .Attachments.Count
strAttNames = strAttNames & "[See Attachment: " & _
..Attachments(intC).FileName & "]"
Next intC
'.htmlBody = .htmlBody & "<BR><BR>" & strAttNames
SendKeys strAttNames
'.Body = .Body ' reset the body using default editor setting
End If
End With
End If
Set itmMessage = Nothing
End Sub


hope this helps someone
 
Back
Top