Inclusion of DocProperty in email subject and body

S

Sean

I am trying to send a document with a pre-written message
in the body. It also should include values of
DocumentProperties in the document. When the macro runs
the Document Properties are changed and set, however, I
cannot get them to be placed within the body of the
email. The email will generate and send, but the Subject
and the Body of the email will not take the DocProperty
references and generates the lines with blanks in them
where the DocProperty.Value should be. I included part of
the code where the email is written below. Is something
wrong with it.


With oItem
.To = ActiveDocument.CustomDocumentProperties
("ManagerEmail").Value
.Subject = "Associate Consultant Weekly Activity Log -
Week Ending " & ActiveDocument.CustomDocumentProperties
("WeekEndingDate").Value & " - " &
ActiveDocument.CustomDocumentProperties
("ConsultantName").Value
'Add the document as an attachment, you can use
the .displayname property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName,
Type:=olByValue, _
DisplayName:="Document as attachment"
.Body = "Hi " &
ActiveDocument.CustomDocumentProperties
("ManagerName").Value & "," & vbCrLf & vbCrLf & "Here is
my weekly activity log for week ending " &
ActiveDocument.CustomDocumentProperties
("WeekEndingDate").Value & " ." & vbCrLf _
& "Please let me know if you have any questions."
& vbCrLf & vbCrLf &
ActiveDocument.CustomDocumentProperties
("ConsultantName").Value
.Send

End With
 
D

Doug Robbins

Try declaring String variables and load them with the value of the fields
and then use them in your code.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
S

Sean

I actually had done that first (Dim strDate As String,
etc.; strDate = ActiveDocument.CustomDocumentProperties
("ManagerEmail").Value) but then I just wrote in the
DocProperty.Value lines when it failed
..
For some reason the email address gets filled in but the
Manager Name, Date, and other fields do not.. both in
using the string variables and DocProperty direct
references.

Thanks,
sean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top