Outlook Notification For New Work Items At Task Level
Adrian Clarke
adrian.clarke at xchanging.com
Thu Mar 11 06:28:27 EST 2010
We implemented an SMTP solution. This needs access from your SAP server
(batch job server if you have more than one) to your SMTP server (both
network and relays on the SMTP server) and a script like the one below.
The details are put into a file of the mail that is required to be sent,
and then a job run to run this script. The script is for a Windows
platform, written in VBScript, but could easily be rewritten in
JavaScript. For Unix, I would suggest using one of the mail sending
utilities like sendmail, qmail, procfix etc to send a mail using SMTP.
The file has parameters within it - see the end of the script for an
example file.
'
' file_mail.vbs
'
' Usage
' =====
'
' cscript file_mail.vbs [parameters]
'
'
' Parameters
' ==========
'
' -d:filename File of parameters and HTML data to use as the
message body.
' Use "-d:filename" if there are spaces in the
filename
'
' -a:filename Optional file to attach to all mails.
' Use "-a:filename" if there are spaces in the
filename.
'
'
'
' File Contents
' =============
'
' **f:emailaddr Specify the e-mail address of the sender
' **t:emailaddrs Specify the e-mail address of the receiver(s)
separated by semi-colon
' **c:emailaddrs Specify the e-mail address of the carbon copy(s)
separated by semi-colon
' **b:emailaddrs Specify the e-mail address of the blind copy(s)
separated by semi-colon
' (note the address sapteam at mycompany.com is added to
ensure a copy)
' **s:subject Specify the e-mail subject
' **a:filename File to attach to this mail only. Either use -a on
the call to the script
' (to get the same attachment(s) for each mail) or
**a in the file to get
' different attachment(s) for each mail)
' **x Send the mail. You must specify **x on a line on its
own if you wish to
' send multiple mails from the same data file
' (all others) The line is part of the HTML body of the mail
'
' Example
' =======
'
' cscript file_mail.vbs -d:\\srv12345\email\data\SAP_Urgent.txt
'
' The above would send a mail using the parameters contained within
the file
' \\srv12345\email\data\SAP-Urgent.txt.
' Please note that the whole of the parameter, including the -d:
would have to be
' put into quotes if there was a space anywhere in the filename.
' If variables are being used to populate the parameters always use
quotes where a space
' could be within the parameter - e.g. cscript file_mail.vbs
"-d:%1" "-a:%2"
'
'
' Notes
' =====
'
' The environment variable SAPSystemName is used to find out what SAP
system, if any, may be
' using this script. If it finds the variable, and it has an entry that
does not start with
' "P" (i.e. finds a non-production system), it will add the system name
to start of the subject
' within square brackets (e.g. "[DEV] Subject of mail")
'
Dim fso, tStream, oArgs
Dim sSMTPHost, strServer
Dim objEmail
Dim sBCC, sSubject, sDataFile, sAttach, w_line, w_body
Dim ObjBP
WScript.Echo "*i : file_mail version AC090713 starting"
Set oArgs = WScript.Arguments
'*** Save the Arguments in variables that are more descriptive...
for x=0 to oArgs.count - 1
if Left(cstr(oArgs(x)),3) = "-d:" then
sDataFile = Mid(cStr(oArgs(x)),4)
elseif Left(cstr(oArgs(x)),3) = "-a:" then
sAttach = Mid(cStr(oArgs(x)),4)
else
WScript.Echo "*w : unknown parameter " & cstr(oArgs(x)) & " -
parameter ignored"
end if
next
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("PROCESS")
strServer = WshSysEnv("SAPSYSTEMNAME")
if strServer <> "" AND left(strServer, 1) <>"P" then
sSubject = "[" & strServer & "] "
end if
on error resume next
sSMTPHost = "10.1.2.3"
Set objEmail = CreateObject("CDO.Message")
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/con
figuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/con
figuration/smtpserver") =
sSMTPHost
objEmail.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25
objEmail.Configuration.Fields.Update
If sAttach > "" Then
objEmail.AddAttachment sAttach
If err.number > 0 Then
wscript.echo "*i: Attach File " & sAttach & " - Error " &
CStr(Err.Number) & " " &
Err.Description
Else
wscript.echo "*i: Attach File " & sAttach & " - file has been
attached"
End If
End If
If sDataFile > "" Then
Set fso = CreateObject("Scripting.FileSystemObject")
Set tStream = fso.OpenTextFile(sDataFile, 1)
If err.number > 0 Then
wscript.echo "*i: Body File " & sDataFile & " - Error " &
CStr(Err.Number) & " " &
Err.Description
Else
sBCC = "sapteam at mycompany.com"
w_body = ""
while not tstream.AtEndOfStream
w_line = tstream.readline
if left(w_line,4) = "**f:" or left(w_line,4) = "**F:" then
objemail.From = mid(w_line,5)
elseif left(w_line,4) = "**t:" or left(w_line,4) = "**T:" then
objemail.To = mid(w_line,5)
elseif left(w_line,4) = "**c:" or left(w_line,4) = "**C:" then
objemail.CC = mid(w_line,5)
elseif left(w_line,4) = "**b:" or left(w_line,4) = "**B:" then
if len(w_line) = 4 then
sBCC = "sapteam at mycompany.com"
else
sBCC = mid(w_line,5) & ";sapteam at mycompany.com"
end if
elseif left(w_line,4) = "**s:" or left(w_line,4) = "**S:" then
objemail.Subject = sSubject & mid(w_line,5)
elseif left(w_line,4) = "**a:" or left(w_line,4) = "**A:" then
objemail.AddAttachment mid(w_line,5)
elseif w_line = "**x" or w_line = "**X" then
objemail.bcc = sBCC
objemail.HTMLbody = w_body
objemail.Send
w_body = ""
set objBP = objemail.bodypart.bodyparts
objBP.deleteall
else
if w_body = "" then
w_body = w_line
else
w_body = w_body & " " & w_line
end if
end if
wend
End If
tStream.Close
fso.deletefile(sDataFile)
If err.number > 0 Then
wscript.echo "*i: Body File " & sDataFile & " - Error " &
CStr(Err.Number) & " " &
Err.Description
End if
End If
if w_body > "" then
objemail.bcc = sBCC
objemail.HTMLbody = w_body
objEmail.Send
End If
WScript.Echo "*i : file_mail finished"
WScript.Quit
Here is an example file:
**f:adrian.clarke at xchanging.com
**t:ali.husain at sap.wug
**s:Example File
Ali,<BR><BR>This is an example of a file that can be
used to
send
a mail or two without the need for using SCOT or any
other tools within SAP.<BR><BR>Regards,<BR><BR>Adrian
**x
**t:bart.simpson at wasnot.me.uk
**s:I have the proof
**a:\\srv12345\pictures\kcc.jpg
Bart,<BR><BR>As you can see from the attached I have proof it was you.
You will find this also <A
HREF="http://www.proof.com">online<A>.<BR><BR>Confess!<BR><BR>Adrian
This will send a mail from adrian.clarke at xchanging.com to
ali.hisain at sap.wug with a subject of "Example File". The body of the
mail will be formatted in HTML as follows:
Ali,
This is an example of a file that can be used to send a mail or two
without the need for using SCOT or any other tools within SAP
Regards,
Adrian
The second mail will also be sent from adrian.clarke at xchanging.com
(there is no need to repeat the **f parameter, but it does no harm to),
to bart.simpson at wasnot.me.uk. The subject of the mail will be "I have
the proof" and there will be an attachment of kcc.jpg found in the
pictures directory of the srv12345 server.
The mail body will have a link in it to www.proof.com
<http://www.proof.com/> .
There is no need for **x at the end, as if there is an unsent mail body,
it will be sent, but again, it does not harm.
With Best Wishes
Adrian Clarke
SAP Consultant
Xchanging
________________________________
From: sap-wug-bounces at mit.edu [mailto:sap-wug-bounces at mit.edu] On Behalf
Of Ali Husain
Sent: 11 March 2010 10:19
To: SAP WUG
Subject: Outlook Notification For New Work Items At Task Level
Hey guys,
Is there a way to send an Outlook notification to the agent whenever he
has a new Work Item in his inbox without using an explicit mail step in
the WF template?
I also want to avoid Extended Notifications for now and also the BG job
RSWUWFML. I don't need to send a link to execute the WI, just a
notification so that the agent knows and then can access his inbox via
Portal (We are on ECC 6 but not using UWL yet).
So i was wondering if there is a simple quick solution at the task level
to achieve this.
Thanks a lot for the help.
Ali
________________________________
Hotmail: Free, trusted and rich email service. Get it now.
<http://clk.atdmt.com/GBL/go/201469228/direct/01/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/sap-wug/attachments/20100311/5c4a7a86/attachment.htm
More information about the SAP-WUG
mailing list