Send an Email to the User Logged In

P

PatrickA

All,

We have a process users must log into (RDP) a remote PC to complete.
They log in, they start the process, they close the connection. They
come back later and peek in the oven to see if it's baked.

I want to send an email to a user once the process has completed.

Thanks to Graham Mayor's posts on the topic of sending email via
macros, I have 90% of what I need.

The other 10% are:

1, How do I get around the MSO "warning box" that tells me that a
program is automatically trying to send email on my behalf?
Otherwise, the email never gets sent, as the user isn't monitoring the
remote PC.

2. How do I retrieve the current user's email address from the
system?

The code I am using (nearly a cut and past of Graham's) is below.

Any suggestions?

Thanks,

Patrick
_____________________________________________________________________________________________

Sub Baked()

Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
'I added the Outlook Object Library to VBA Tools References
Dim oItem As Outlook.MailItem
On Error Resume Next

'see if Outlook is running and if so turn your attention there
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then 'Outlook isn't running
'So fire it up
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

'Open a new e-mail message
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem 'and add the detail to it
.To = "CURRENT USER ADDRESS" 'send to this address
.Subject = "Your D3 Documents Are Ready" 'This is the message
subject
.Send
End With
If bStarted Then 'If the macro started Outlook, stop it again.
oOutlookApp.Quit
End If
'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub
 
D

Doug Robbins - Word MVP

For the first issue, see the information on the Express Click Yes utility in
the article "Mail Merge to E-mail with Attachments" at:

http://word.mvps.org/FAQs/MailMerge/MergeWithAttachments.htm

For the email address, you may have to include a request for the use to
supply their email address as part of the process that they initiate.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

Graham Mayor

The ClickYes utility Doug mentioned is linked from my web site.
The current user's address can be obtained in the macro from the Outlook
object with

oOutlookApp.Session.CurrentUser.Address

Thus

With oItem 'and add the detail to it
.To = oOutlookApp.Session.CurrentUser.Address 'send to this address


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

PatrickA

Graham, Doug,

You guys made my morning!!!!

Thanks, these two pieces together provide the final 10%.

Patrick
 

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