kfschaefer
06-13-2006, 10:50 AM
I have code that will send an email upon completion of the task, it looks at the userid and returns the email address. Atleast on the local machine.
When I tried the code on another it could not find the email address for that userid.
Is there such code that will do somekindof cross reference or DLOOKUP on the Outlook global address book?
Public Function ReturnNetworkName() As String
'RETURNS NETWORK LOGIN ID OF CURRENT USER
ReturnNetworkName = Environ("UserName")
End Function
Function SendMessage() 'DisplayMsg As Boolean, Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
'Dim objOutlookAttach As Outlook.Attachment
Dim strLtrContent, strLtrContentEnd, strHyperLink
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(ReturnNetworkName)
objOutlookRecip.Type = olTo
strLtrContent = "The most recent PLANIT is avail for you to copy to your local drive and scrub in your Core Scenario Planning and Dimensioning." & _
vbCrLf & vbCrLf & "Please Click on the following link, this will direct you to a SAVE AS dialog box, which defaults to your [MY Document] file, you can Click OK or redirect to the desired directory." & _
vbCrLf & vbCrLf & " "
strLtrContentEnd = "For 'Missing Node', 'Missing Market' or 'Missing Region' issues, please email Karen Schaefer. For trending related issues, please email or call Tanvir Rahman."
strHyperLink = "RegionFileCopy.mdb"
.Subject = "Manual PlanIT Forecast for Scrubbing is Completed and Ready for Your Use for the NCP"
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><HEAD><META http-equiv=Content-Type content=" & Chr$(34) & "text/html; charset=iso-8859.1" & Chr$(34) & "></HEAD>" & vbCrLf & _
"<BODY>" & strLtrContent & "<A HREF=" & Chr$(34) & strHyperLink & Chr$(34) & ">" & strHyperLink & "</A><br><p>" & strLtrContentEnd & "</BODY></HTML>"
.Send
End With
' Resolve each Recipient's name.
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Function
Thanks,
Karen :banghead: :banghead: :banghead: :banghead:
When I tried the code on another it could not find the email address for that userid.
Is there such code that will do somekindof cross reference or DLOOKUP on the Outlook global address book?
Public Function ReturnNetworkName() As String
'RETURNS NETWORK LOGIN ID OF CURRENT USER
ReturnNetworkName = Environ("UserName")
End Function
Function SendMessage() 'DisplayMsg As Boolean, Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
'Dim objOutlookAttach As Outlook.Attachment
Dim strLtrContent, strLtrContentEnd, strHyperLink
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(ReturnNetworkName)
objOutlookRecip.Type = olTo
strLtrContent = "The most recent PLANIT is avail for you to copy to your local drive and scrub in your Core Scenario Planning and Dimensioning." & _
vbCrLf & vbCrLf & "Please Click on the following link, this will direct you to a SAVE AS dialog box, which defaults to your [MY Document] file, you can Click OK or redirect to the desired directory." & _
vbCrLf & vbCrLf & " "
strLtrContentEnd = "For 'Missing Node', 'Missing Market' or 'Missing Region' issues, please email Karen Schaefer. For trending related issues, please email or call Tanvir Rahman."
strHyperLink = "RegionFileCopy.mdb"
.Subject = "Manual PlanIT Forecast for Scrubbing is Completed and Ready for Your Use for the NCP"
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><HEAD><META http-equiv=Content-Type content=" & Chr$(34) & "text/html; charset=iso-8859.1" & Chr$(34) & "></HEAD>" & vbCrLf & _
"<BODY>" & strLtrContent & "<A HREF=" & Chr$(34) & strHyperLink & Chr$(34) & ">" & strHyperLink & "</A><br><p>" & strLtrContentEnd & "</BODY></HTML>"
.Send
End With
' Resolve each Recipient's name.
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Function
Thanks,
Karen :banghead: :banghead: :banghead: :banghead: