VTJ
objOutlookEmail.CC = "<insert name and path here>"
or
objOutlookEmail.CC = strcc
(as appropriate) works for me using ver 7 & Outlook/Exchange server.
HTH
lex
Thanks for your reply. Unforunately I've not been able to get it to work. When I past it into the script and try to compile I get an error objOutlookEMail.cc is not a valid object. I'm trying different combinations of your solution and will let you know if anything changes.
The string objOutlookEmail provided by lex above is a named object within your macro. You may have declared it with a different name, which is fine, but you have to be consistent. See thread401-249399 for more information. Or use the Keyword search here in the Cognos forum on 'Outlook'.
Regards,
Dave Griffin
The Decision Support Group
Reporting Consulting with Cognos BI Tools
"Magic with Data" Want good answers? Read FAQ20-2863 first!
Sorry if I seem a bit dense. This is my original script.
Function Email(Message as String)
Dim objSession As Object
Dim objMessage As Object
Dim objRecipient As Object
Dim sProfile As String
'You can specify any name you desire
sProfile = "Company Exchange"
' Create the Session Object.
Set objSession = CreateObject("mapi.session"
objSession.Logon profileName:=sProfile
' Add a new message object to the OutBox.
Set objMessage = objSession.Outbox.Messages.Add
' Set the properties of the message object.
objMessage.Subject = "Errors occured during update"
objMessage.Text = Message
' Add a recipient object to the objMessage.Recipients collection.
Set objRecipient = objMessage.Recipients.Add
' Set the properties of the recipient object.
objRecipient.Name = "firstname.lastname"
objRecipient.Resolve
' Send the message. Setting showDialog to False
' sends the message without displaying the message
' or requiring user intervention. A setting of True
' displays the message and the user must choose
' to Send from within the message dialog.
objMessage.Send showDialog:=False
' Log off using the session object.
objSession.Logoff
End Function
Sub Main()
EMAIL "Reports did not update The problem is being investigated"
End Sub
Here is the new one.
Function Email(Message as String)
Dim objSession As Object
Dim objMessage As Object
Dim objRecipient As Object
Dim objOutlookEMail As Object
Dim sProfile As String
'You can specify any name you desire
sProfile = "Company Exchange"
' Create the Session Object.
Set objSession = CreateObject("mapi.session"
objSession.Logon profileName:=sProfile
' Add a new message object to the OutBox.
Set objMessage = objSession.Outbox.Messages.Add
' Set the properties of the message object.
objMessage.Subject = "Errors occured during update"
objMessage.Text = Message
' Add a recipient object to the objMessage.Recipients collection.
Set objRecipient = objMessage.Recipients.Add
set objOutlookEMail = objMessage.Recipients.add
' Set the properties of the recipient object.
objOutlookEMail.Name = "firstname.lastname"
objRecipient.Name = "firstname.lastname"
objRecipient.Resolve
' Send the message. Setting showDialog to False
' sends the message without displaying the message
' or requiring user intervention. A setting of True
' displays the message and the user must choose
' to Send from within the message dialog.
objMessage.Send showDialog:=False
' Log off using the session object.
objSession.Logoff
End Function
Sub Main()
EMAIL "Reports did not update The problem is being investigated"
VTJ,
I'm still learning scripting, so haven't reached functions and defining them. Dave Griffin is quite right regarding objects; I'm afraid I assumed you had used a standard naming convention.
I just tend to add the following to the end of my scripts to notify people of completed jobs and perhaps attach files.
...
Dim objOutlookEmail as Object
Dim objOutlookAttachments as Object
'Other variables set earlier
Set objOutlookEmail = objOutlook.CreateItem(OlMailItem)
objOutlookEmail.To = "lex.w@acme.co.uk"
objOutlookEmail.CC = "my.chum@acme.co.uk
objOutlookEmail.Body = "Herewith claimback report"
objOutlookEmail.Subject = "Claimback " + " " + Format(strstartd,"Mmm-yy"
Set objOutlookAttachments = objOutlookEmail.Attachments
strtemp = strloc & strfilename & ".xls"
objOutlookAttachments.Add strtemp
objOutlookEmail.Send
Set objOutlookEmail = Nothing
Set objOutlook = Nothing
...
It's not as clever as a function, but then, I'm not that clever either!
regards,
lex
There may be syntax differences between using OLE with Outlook itself versus using Mapi. I would try using the .cc method with the objMessage object in the following location:
You may encounter other issues macro functions return values and yours doesn't appear to do so. Nor is the calling code line setup to receive one. May be an issue or not, you'll have to see.
Regards,
Dave Griffin
The Decision Support Group
Reporting Consulting with Cognos BI Tools
"Magic with Data" Want good answers? Read FAQ20-2863 first!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.