• 0

VBS - UserProfile Path and File


Question

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

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

1:\ Use code brackets for code, it makes it easier to read


Test Code Here
[/CODE]

2:\ Have you thought of making a variable for the pathway

Example

[CODE]
Dim Act :Set Act = CreateObject("Wscript.Shell")

Dim Dtop :Dtop = Act.ExpandEnvironmentStrings( _
"%UserProfile%" & "\Desktop")
[/CODE]

3:\ How are you coding the path in the script?

Link to comment
Share on other sites

This topic is now closed to further replies.