Powerpoint97 - Automate EMail

  • Thread starter Thread starter Simon
  • Start date Start date
S

Simon

I have a Ppt slideshow that it is my intention to email to
all our staff.

I would like to add several buttons to the final slide of
the slideshow that allow the users to indicate a choice.

On clicking on one of the command buttons I would like an
email returned to myself indicating the choice made by the
user.

We are using Lotus Notes as our email client.

I thought that it might be possible to use VBA code to set
and follow a hyperlink such as "mailto:[email protected]", and
then maybe use SendKeys to fill in the text of the email.

Obviously this was only one thought.

I would be very grateful of any suggestions on how to do
this.

BTW, I can't assume that the users have the Lotus Notes
object library referenced, but I suppose that I could set
the reference in the code and then use the Notes objects/
classes???

Thanks
 
You can even set up the subject line and a SHORT message text using the
mailto hyperlink. From some research I have done previously:

There is a limit: The entire mailto statement must be less that 256
characters.

To set it up, create a hyperlink on a shape. Select email address. Put your
email address in the first field and your subject in the second field. After
you finish your subject, hit the space bar. Now, type "&body" (without the
quotes) and your message body. An example subject might look like this:

Button%20clicked%20was%20choice%20number%20one.
(each %20 is a space)

Play around with it and see if you can make it work.
--
Kathryn Jacobs, Microsoft MVP PowerPoint and OneNote
Author of Kathy Jacobs on PowerPoint - Available now from Holy Macro! Books
Get PowerPoint answers at http://www.powerpointanswers.com
Featured Presenter at PPT 2004 - http://www.pptlive.com

I believe life is meant to be lived. But:
if we live without making a difference, it makes no difference that we lived
 
You're in luck. Been there, done that! The following is broke up into
three sections. The first one is the basic code to send an e-mail via Lotus
notes. The second section is a brief example of how to use variables to
capture information to be sent out. The third part incorporates that
information into the Lotus Notes code. Be sure to go into the VBE window,
click "Tools", "references", and scroll down and click the "Lotus Notes..."
reference.

Be patient and calm as this will be sort of long:

=======Start of Section One======

Dim Session As Object, DB As Object, Memo As Object
Dim Server$, Mailfile$
Dim Item As Object, strSubject As String, strBody As String

strSubject = "Put your subject here"

Set Session = CreateObject("Notes.NotesSession")

' Read the current mail server from Notes.ini
Server$ = Session.GETENVIRONMENTSTRING("MailServer", True)

' Read the current mail file from Notes.ini
Mailfile$ = Session.GETENVIRONMENTSTRING("MailFile", True)

' Try to open the mail database
Set DB = Session.GETDATABASE(Server$, Mailfile$)

' If Mail db not accessible, return an error
If Not DB.IsOpen Then
MsgBox "Could not access Notes mail file! Please contact blah, blah, blah."
Exit Sub
End If

'LN Message
'Create a memo in the user's mail file
Set Memo = DB.CREATEDOCUMENT

'Set the form to be a mail memo
Memo.Form = "Memo"
Memo.copyto = "wherever"

'Set the "from" field (not necessary)
Memo.From = Session.UserName

'Set the recipient of the memo (you will change this for your presentation -
PLEASE)!
Memo.SendTo = "put your e-mail address here"

'Give the memo a subject
Memo.Subject = strSubject

'Give the memo a body message
Memo.Body = "Put your memo body text here"

'Sends the memo and does not save the message
Call Memo.SEND(False, False)

' Restore NOTES variables back to nothing
Set DB = Nothing
Set Session = Nothing

=======End of Section One======

=======Start of Section Two=====

I usually have some variables declared that hold certain information like
LastName, FirstName, EmployeeID, etc. I might capture this on a UserForm
from a macro on the first slide. You can set these variables to text inside
a textbox on a slide, etc. The trick is to know the name of the object on
the slide (like AutoShape4), or give it a unique name using the below macro:

Sub NameShape()
Dim Name$
On Error GoTo AbortNameShape

If ActiveWindow.Selection.ShapeRange.Count = 0 Then
MsgBox "No Shapes Selected"
Exit Sub
End If
Name$ = ActiveWindow.Selection.ShapeRange(1).Name

Name$ = InputBox$("Give this shape a name", "Shape Name", Name$)

If Name$ <> "" Then
ActiveWindow.Selection.ShapeRange(1).Name = Name$
End If
Exit Sub

AbortNameShape:
MsgBox Err.Description

End Sub

Once you have this information captured, instead of attaching a PowerPoint
file with the information on one slide, put that info into variables and
send those variables in the body of the message. The last section provides
a sample!

=======End of Section Two=====

=======Start of Section Three====

This is the same code as above with a few variables that I captured in the
body of the message. Obviously you would need to have these variable names
changed to capture the info you want. Here goes:

Dim Session As Object, DB As Object, Memo As Object
Dim Server$, Mailfile$
Dim Item As Object, strSubject As String, strBody As String

strSubject = strLessonNumber & ", " & strLessonTitle & " CBT Completed"

Set Session = CreateObject("Notes.NotesSession")

' Read the current mail server from Notes.ini
Server$ = Session.GETENVIRONMENTSTRING("MailServer", True)

' Read the current mail file from Notes.ini
Mailfile$ = Session.GETENVIRONMENTSTRING("MailFile", True)

' Try to open the mail database
Set DB = Session.GETDATABASE(Server$, Mailfile$)

' If Mail db not accessible, return an error
If Not DB.IsOpen Then
MsgBox "Could not access Notes mail file! Please call yours truly to
receive credit."
Exit Sub
End If

'LN Message
'Create a memo in the user's mail file
Set Memo = DB.CREATEDOCUMENT

'Set the form to be a mail memo
Memo.Form = "Memo"
Memo.copyto = "wherever"

'Set the "from" field (not necessary)
Memo.From = Session.UserName

'Set the recipient of the memo (you will change this for your presentation -
PLEASE)!
Memo.SendTo = "put your e-mail address here"

'Give the memo a subject
Memo.Subject = strSubject

'Give the memo a body message
Memo.Body = "I have reviewed the presentation. I scored " & Format(Score,
"00.0%") & _
" on the quiz." & Chr(10) & "First name: " & strfirstname & Chr(10) & _
"Last name: " & strlastname & Chr(10) & "SSN: " & strSSN

'Send the memo
Call Memo.SEND(False, False)

' Restore NOTES variables back to nothing
Set DB = Nothing
Set Session = Nothing

======End of Section Three====

If you want, you can check out my CBT demo at:

http://www.pttinc.com/cbt_development.html

Holler if you have questions!
 
This sounded like the easiest option. However, I can't
seem to get it working. A new memo is opened with the To
field populated, but no subject or body.

What might I be doing wrong? Could you possibly talk me
through exactly what I need to do?

Ta
 
Ummm.. That was the exact steps :) (Just tried it. I missed one character,
the equals sign before the &body. That made the body part not work, but your
subject should have worked.)

Try exactly this:
1) Create a shape to be the button
2) Right click the shape and select "Hyperlink"
3) Click the "Email Address" button in the left column
4) Click in the "Email address:" field and type the address
5) Click in the "Subject:" field and type "Your subject" (without the
quotes)
6) Add a space after "Your subject"
7) After the space, type "=&bodyUser%20clicked%20button%20one"(without the
quotes)
8) Click the OK button

The button will only work in slide show mode. Try it and see what you get.
Once the basic one is working, change "Your subject" to the real subject and
the body text to the real text.

Let me know how it goes.
--
Kathryn Jacobs, Microsoft MVP PowerPoint and OneNote
Author of Kathy Jacobs on PowerPoint - Available now from Holy Macro! Books
Get PowerPoint answers at http://www.powerpointanswers.com
Featured Presenter at PPT 2004 - http://www.pptlive.com

I believe life is meant to be lived. But:
if we live without making a difference, it makes no difference that we lived
 
Back
Top