• SendMail woes…. (Word 97)

    Author
    Topic
    #358592

    Hi!

    I was wondering if anyone has been able to accomplish the following (in Word 97, of course):

    Send the current document to a specific recipient with a specific subject line (ie. with sendmail),
    or use a hyperlink to send email (because you can specify recipient and subject) and automatically attach the document.

    This really has me stumped. I was able to do something similar in Excel, but it doesn’t seem to be available in Word. Or am I looking in the wrong place?

    Thanks in advance,

    Cecilia smile

    Viewing 0 reply threads
    Author
    Replies
    • #535410

      Word 97 (not sure about the others) has a really, really
      wimpy sendmail method. In other words, in the real world it’s
      useless. After adding a reference to the Outlook Object
      Library (or dim all objects as Object), try this instead:

      Sub cmdSendADoc()
          Dim objOutlook As Outlook.Application
          Dim nsMAPI As Outlook.NameSpace
          Dim objOutbox As Outlook.MAPIFolder
          Dim objNewMessage As Outlook.MailItem
      
          Set objOutlook = New Outlook.Application
          Set nsMAPI = objOutlook.GetNamespace("MAPI")
          Set objOutbox = nsMAPI.GetDefaultFolder(olFolderInbox)
          Set objNewMessage = objOutbox.Items.Add
      
          If Not ActiveDocument.Saved Then
              ActiveDocument.Save
          End If
          
          With objNewMessage
              .To = "TheBoss"
              .Subject = "Your custom subject line"
              .Attachments.Add activedocument.fullname
              .Send
          End With
          Set objOutlook = Nothing
          Set nsMAPI = Nothing
          Set objOutbox = Nothing
          Set objNewMessage = Nothing
      End Sub
      
    Viewing 0 reply threads
    Reply To: SendMail woes…. (Word 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: