Jump to content



Photo

VBS - UserProfile Path and File

vbs userprofile variables

  • Please log in to reply
1 reply to this topic

#1 brink668

brink668

    Neowinian

  • Joined: 12-September 07

Posted 16 April 2013 - 15:37

Set olApp = CreateObject("Outlook.Application")
Set olMsg = olApp.CreateItem(0)
Set objShell=CreateObject("Wscript.Shell")
With olMsg
'.To = "test@test.com"
'.CC = "cc@testing.com"
'.BCC = "bcc@testing.com"
.Subject = "While You Were Out: "

.HTMLBody = "<html><p></p>" & _
"<img src='cid:wywo_notification.jpg'>"

I am having trouble with this part. I cant get the file and the userprofile piece to work correctly.
.Attachments.Add strHomeFolder = oShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\wywo_notification.jpg"

The below direct path works but not when adding the userprofile variable
'.Attachments.Add "C:\users\doej\wywo_notification.jpg"

.Display
End With


#2 jake1eye

jake1eye

    Neowinian

  • Joined: 02-April 03
  • Location: New Westminster

Posted 16 April 2013 - 17:39

1:\ Use code brackets for code, it makes it easier to read
Test Code Here
2:\ Have you thought of making a variable for the pathway
Example
Dim Act :Set Act = CreateObject("Wscript.Shell")

Dim Dtop :Dtop = Act.ExpandEnvironmentStrings( _
  "%UserProfile%" & "\Desktop")
3:\ How are you coding the path in the script?