Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add CC recipient to a cognos email script

Status
Not open for further replies.

vtj

MIS
May 24, 2001
31
0
0
US
I've created an email script to email pdfs to multiple users. I would like to add a cc to those emails. Does anyone know how to do this?

We use Outlook as our corporate email system.

Thanks,

Vtj

VTJ
 
VTJ
objOutlookEmail.CC = &quot;<insert name and path here>&quot;
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.

I'm using Outlook 2000 and COGNOS 7.0

VTJ
 
vtj,

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
&quot;Magic with Data&quot;
[pc2]
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 = &quot;Company Exchange&quot;

' Create the Session Object.
Set objSession = CreateObject(&quot;mapi.session&quot;)
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 = &quot;Errors occured during update&quot;
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 = &quot;firstname.lastname&quot;
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 &quot;Reports did not update The problem is being investigated&quot;

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 = &quot;Company Exchange&quot;

' Create the Session Object.
Set objSession = CreateObject(&quot;mapi.session&quot;)
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 = &quot;Errors occured during update&quot;
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 = &quot;firstname.lastname&quot;
objRecipient.Name = &quot;firstname.lastname&quot;
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 &quot;Reports did not update The problem is being investigated&quot;

End Sub


Any help with the syntax would be very helpful.


VTJ
 
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 = &quot;lex.w@acme.co.uk&quot;
objOutlookEmail.CC = &quot;my.chum@acme.co.uk
objOutlookEmail.Body = &quot;Herewith claimback report&quot;
objOutlookEmail.Subject = &quot;Claimback &quot; + &quot; &quot; + Format(strstartd,&quot;Mmm-yy&quot;)
Set objOutlookAttachments = objOutlookEmail.Attachments
strtemp = strloc & strfilename & &quot;.xls&quot;
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
 
vtj,

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:

objMessage.Subject = &quot;Errors occured during update&quot;
objMessage.Text = Message
objMessage.cc = &quot;address string&quot;

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
&quot;Magic with Data&quot;
[pc2]
Want good answers? Read FAQ20-2863 first!
 
Thanks for the help. I'll try it and let you know. You may be right about the mapi.

Thanks

VTJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top