Edit MailEnvelope.Item Before .Send

G

Guest

The following is part of some coder I am using to send a word document as the
message body of an email.

Set Report = doc.MailEnvelope.Item
Report.To =
Report.Subject =
Report.Send

This nicely send the document and without "ClickYes" you have to approve the
send.
Can someone tell me how to trigger an edit so the email opens requiring the
user to manually send the email? Thank you.
 
S

Sue Mosher [MVP-Outlook]

Tell us more about doc. Is this document already displayed? Or is it a document you are creating programmatically?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

I pieced together the following using some of your old posts and help from
Doug Robbins:

DoCmd.OutputTo acOutputReport, "Name Of Access Report", acFormatRTF,
"FullPath and name of output document.rtf"

Dim wdApp As Word.Application
Dim doc As Word.Document
Dim Report As MailItem

Set wdApp = New Word.Application
Set doc = wdApp.Documents.Open("FullPath and name of output document.rtf
")
Set Report = doc.MailEnvelope.Item

Report.To = "emailaddressof recipient"
Report.Subject = "email subject"
Report.Send

wdApp.Quit False
Set doc = Nothing
Set wdApp = Nothing

Kill ("FullPath and name of output document.rtf ")

The above is running from a command button in MS Access. I am using Office
2003. The purpose is to get a readable report for a Blackberry user. Thank
you for your help.


--
Jeff C
Live Well .. Be Happy In All You Do


Sue Mosher said:
Tell us more about doc. Is this document already displayed? Or is it a document you are creating programmatically?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

So, the document is not already visible. Do you want the user to edit it in Word or Outlook?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Jeff C said:
I pieced together the following using some of your old posts and help from
Doug Robbins:

DoCmd.OutputTo acOutputReport, "Name Of Access Report", acFormatRTF,
"FullPath and name of output document.rtf"

Dim wdApp As Word.Application
Dim doc As Word.Document
Dim Report As MailItem

Set wdApp = New Word.Application
Set doc = wdApp.Documents.Open("FullPath and name of output document.rtf
")
Set Report = doc.MailEnvelope.Item

Report.To = "emailaddressof recipient"
Report.Subject = "email subject"
Report.Send

wdApp.Quit False
Set doc = Nothing
Set wdApp = Nothing

Kill ("FullPath and name of output document.rtf ")

The above is running from a command button in MS Access. I am using Office
2003. The purpose is to get a readable report for a Blackberry user. Thank
you for your help.
 
G

Guest

I would like the edit to occur in Outlook

I altered the previous code to:

Report.To = "recipientAddress"
Report.Subject = "Subject"
Report.Save
ID = Report.EntryID

Set OL = CreateObject("Outlook.Application")
Set NS = OL.GetNamespace("MAPI")
Set Msg = NS.GetItemFromID(ID)
Msg.Display (True)


'Report.Send



wdApp.Quit False
Set doc = Nothing
Set wdApp = Nothing

Kill ("Path and name of output")

This creates a Draft email in Outlook without opening for edit and the
Message body is an actual WORD Document with pages which I don't get with the
initial code. The initial code works great sending one long email message
body, I just thought it would be a nice touch being able to add a few lines
at the beginning if the user wanted.

It's an interesting process putting all these applications together in one
sequence. Thank you.
 
S

Sue Mosher [MVP-Outlook]

Another approach would be to provide a user form where the user can type in the comments they want to add. Then you can set the Introduction property:

doc.MailEnvelope.Introduction = "some text"
Set Report = doc.MailEnvelope.Item

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Jeff C said:
I would like the edit to occur in Outlook

I altered the previous code to:

Report.To = "recipientAddress"
Report.Subject = "Subject"
Report.Save
ID = Report.EntryID

Set OL = CreateObject("Outlook.Application")
Set NS = OL.GetNamespace("MAPI")
Set Msg = NS.GetItemFromID(ID)
Msg.Display (True)


'Report.Send



wdApp.Quit False
Set doc = Nothing
Set wdApp = Nothing

Kill ("Path and name of output")

This creates a Draft email in Outlook without opening for edit and the
Message body is an actual WORD Document with pages which I don't get with the
initial code. The initial code works great sending one long email message
body, I just thought it would be a nice touch being able to add a few lines
at the beginning if the user wanted.

It's an interesting process putting all these applications together in one
sequence. Thank you.
 
G

Guest

Thank you Sue, This is very new to me, I would have no idea how to provide a
form. I had thought initially that displaying the email first rather than
sending directly was only a matter of adding a switch like =True or Display =
yes. Evidently it is much more involved.

Thanks for your help
 
S

Sue Mosher [MVP-Outlook]

I thought you said you already had Msg.Display working?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

The email automatically sends with the initial code I posted. The code
revised as I posted creates a DRAFT copy of the email with the message body
an actualWORD Document, but the email does not open for editing
 
G

Guest

I would like to try your suggestion or providing a **user form** for comments
to be added before this message sends. Can someone guide me with the code I
have posted here what I need to add for some kind of input or form to open
for the user?

Thank you
 
S

Sue Mosher [MVP-Outlook]

The simplest way would be to use an InputBox for a short comment:

txt = InputBox("Please add your comment.", "Add Comment")
doc.MailEnvelope.Introduction = txt
Set Report = doc.MailEnvelope.Item
' etc.
Report.Send

Anything more complicated than a simple comment require a separate VBA user form.

You could also show the Word document to the user with the envelope turned on and the Introduction box showing, couldn't you? And then let the user send the item (which means no security prompt).
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Sue, thank you! That works just great and I appreciate you. Since I have
been finding so much in the Outlook Coding website and with all your help, I
am ordering your book today :).
 

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