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
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