Dynamic result by recipient’s name

P

Pari

I have a procedure that expects last name as a parameter; I am sending out
result of that procedure to multiple recipients, I would like to draft the
email in such a way that data that I send to particular recipient shows ONLY
his results.

Example

Table Structure
-----------------------
Employee Last Name Open Calls
A 10
B 5
C 0

Procedure that will return me result
--------------------------------------------------
Givemeopencalls <lastname>


EMPLOYEE A should receive an email stating “You have 10 Calls openâ€

EMPLOYEE B should receive an email stating “You have 5 Calls openâ€

EMPLOYEE C should receive an email stating “You have 0 Calls openâ€

This whole process I am doing in VB6 and have that exe as a schedule task
running from my machine every day.

Please help
 
E

Eric Legault [MVP - Outlook]

Could you be more specific with the help you need? Are there any particular
issues you're having with the Outlook Object Model? Your business logic is
entirely up to you, but we can help for specific Outlook related stuff.

BTW, running your Outlook code in a Scheduled Task is essentially a
non-starter:

The Outlook Object Model is unsuitable to run in a Windows service:
http://support.microsoft.com/default.aspx?scid=kb;en-us;237913
 
P

Pari

I need to know...is it possible to know the user name (receipient name) from
outlook? I need to pass the receipient's name from the email that was
received and in turn run the procedure that expects a username as a
parameter.
 
E

Eric Legault [MVP - Outlook]

The MailItem.Recipients collection will tell you all that received the
e-mail, but not who the current user is. That requires the
NameSpace.CurrentUser property, but accessing that value from an external
program or script that's automating Outlook will generate a security warning.

You can also use Win32 API calls to get the name of the user logged in to
Windows:

Private Declare Function GetUserName Lib "advapi32.dll" Alias
"GetUserNameA"(ByVal lpBuffer As String, nSize As Long) As Long

Function UserNameWindows() As String

Dim lngLen As Long
Dim strBuffer As String

Const dhcMaxUserName = 255

strBuffer = Space(dhcMaxUserName)
lngLen = dhcMaxUserName
If CBool(GetUserName(strBuffer, lngLen)) Then
UserNameWindows = Left$(strBuffer, lngLen - 1)
Else
UserNameWindows = ""
End If
End Function

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
 
P

Pari

Thanks Eric. This I have already tried, this gives me the username of where
the application is running, I am running the application on my machine that
sends out an email to multiple users, I need to know the user name of the
receipient of the email, so that I can show the results for that user. Is
this possible?
 
E

Eric Legault [MVP - Outlook]

If you are sending the e-mail, wouldn't you already know the recipients you
are sending the e-mail to?? These users are stored as Recipient objects in
the MailItem.Recipients collection. The Recipient.Name property tells you
what the display name of the Recipient is. The MailItem.To property will
also give you a delimited string containing the display names of the message
recipients.

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
 
Top