ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Activate MS Outlook in macro? (https://www.excelbanter.com/excel-programming/362388-activate-ms-outlook-macro.html)

ivan

Activate MS Outlook in macro?
 
Dear all,

I wonder if it is possible to activate MS outlook and send an email to a
specific user with a preset message content in the macro program. Anyone
knows?
Thanks a lot.

Ivan

Bob Phillips

Activate MS Outlook in macro?
 
Dim oOutlook As Object
Dim oMailItem As Object
Dim oRecipient As Object
Dim oNameSpace As Object


Set oOutlook = CreateObject("Outlook.Application")
Set oNameSpace = oOutlook.GetNameSpace("MAPI")
oNameSpace.Logon , , True


Set oMailItem = oOutlook.CreateItem(0)
Set oRecipient = _
om")
oRecipient.Type = 1 '1 = To, use 2 for cc
'keep repeating these lines with
'your names, adding to the collection.
With oMailItem
.Subject = "The extract has finished."
.Body = "This is an automatic email notification"
' .Attachments.Add ("filename") 'you only need this if
'you are sending attachments?
.Display 'use .Send when all testing done
End With

Set oRecipient = False
Set oMailItem = False
Set oNameSpace = False
Set oOutlook = False

--
HTH

Bob Phillips

(replace xxxx in email address with googlemail if mailing direct)

"Ivan" wrote in message
...
Dear all,

I wonder if it is possible to activate MS outlook and send an email to a
specific user with a preset message content in the macro program. Anyone
knows?
Thanks a lot.

Ivan




Bob Phillips

Activate MS Outlook in macro?
 
All the Set object = False at the end should be Set object = Nothing

--
HTH

Bob Phillips

(replace xxxx in email address with googlemail if mailing direct)

"Bob Phillips" wrote in message
...
Dim oOutlook As Object
Dim oMailItem As Object
Dim oRecipient As Object
Dim oNameSpace As Object


Set oOutlook = CreateObject("Outlook.Application")
Set oNameSpace = oOutlook.GetNameSpace("MAPI")
oNameSpace.Logon , , True


Set oMailItem = oOutlook.CreateItem(0)
Set oRecipient = _
om")
oRecipient.Type = 1 '1 = To, use 2 for cc
'keep repeating these lines with
'your names, adding to the collection.
With oMailItem
.Subject = "The extract has finished."
.Body = "This is an automatic email notification"
' .Attachments.Add ("filename") 'you only need this if
'you are sending attachments?
.Display 'use .Send when all testing done
End With

Set oRecipient = False
Set oMailItem = False
Set oNameSpace = False
Set oOutlook = False

--
HTH

Bob Phillips

(replace xxxx in email address with googlemail if mailing direct)

"Ivan" wrote in message
...
Dear all,

I wonder if it is possible to activate MS outlook and send an email to a
specific user with a preset message content in the macro program. Anyone
knows?
Thanks a lot.

Ivan






Tom Ogilvy

Activate MS Outlook in macro?
 
Another source for this type of information:


http://www.rondebruin.nl/sendmail.htm

--
Regards,
Tom Ogilvy


"Ivan" wrote:

Dear all,

I wonder if it is possible to activate MS outlook and send an email to a
specific user with a preset message content in the macro program. Anyone
knows?
Thanks a lot.

Ivan



All times are GMT +1. The time now is 03:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com