I have some code that we use all the time to send an email from Word. Usually I just put the text in the body of the email, or if they need to reference a file, I put a link in the body of the email. However, this email is going out-of-house and needs an attachment. The problem is it seems the attachment isn't added until the email is sent. If I use the display feature, the attachment doesn't show in the draft email. But if I send the email to myself, it does show up in both the email I receive and in the one in my Sent folder. Does anyone have any suggestions on how to have the attachment displayed in the draft email?
Code:
Dim SafeItem, oItem, ccRecipient As Object
Dim olapp As Outlook.Application
Dim nspnamespace As Outlook.NameSpace
Set olapp = Outlook.Application
Set nspnamespace = olapp.GetNamespace("Mapi")
Set SafeItem = CreateObject("cpioutlook.SafeMailItem")
Set oItem = olapp.CreateItem(0)
SafeItem.Item = oItem
SafeItem.Recipients.Add clientemail$
SafeItem.Recipients.ResolveAll
SafeItem.CC = Emailcc$
SafeItem.Subject = EmailSubject1$
SafeItem.body = body$
SafeItem.Attachments.Add savename$, olByValue, 22, EmailSubject$
SafeItem.Display
Set olapp = Nothing
Set nspnamespace = Nothing
Set SafeItem = Nothing
Set oItem = Nothing