Consulting

Results 1 to 3 of 3

Thread: Solved: Putting attachment filenames in a message body.

  1. #1

    Solved: Putting attachment filenames in a message body.

    I'm not a programmer - I'm just using a script that I ran across somewhere on the Internet. I'm using Outlook 2003 on XP. So far this script renames the subject, adds a quick line to the body and then sends the message. I would like it to add the file names of the attachments (plural) to the body after my "inspirational message." Bonus: Can I point my current olItem.Body at a text file? Thanks so much for you help.



    [VBA]Sub ChangeSubject()

    Set oActiveExplorer = Application.ActiveExplorer

    MsgBox TypeName(oActiveExplorer.Selection)

    Set oSelection = oActiveExplorer.Selection

    For I = 1 To oSelection.Count

    Set olItem = oSelection.Item(I)

    olItem.Subject = "Your weekly inspirational message"

    olItem.Body = "Inspirational Message"

    olItem.Send

    Next

    End Sub[/VBA]

  2. #2
    This is about how you'd go about doing what you want...

    [VBA]olItem.Body = "Inspirational Message"

    Dim InspMsg as String

    Dim InFilePath as String

    InFilePath = "C:\test.txt"

    Open InFilePath For Input As 1

    Dim CurrLine as string
    While Not eof( 1 )
    Line Input #1, CurrLine
    InspMsg = InspMsg & vbCr & CurrLine
    Wend

    Close #1

    'Put in a few lines before attachment names
    InspMsg = InspMsg & vbCr & vbCr

    Dim CurrAttch as Attachment
    For Each CurrAttch In olItem.Attachments
    InspMsg = InspMsg & CurrAttach.FileName & vbCr
    Next CurrAttch

    olItem.Body = InspMsg
    [/VBA]

  3. #3
    Thanks so much for you assistance - I really appreciate it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •