How to make path a hyperlink with space in path using powershell -
i using powershell script created email user when files received in folder. problem having of folder paths being watched have space in path breaking hyperlink in email body sent. how can include space doesn't break hyperlink.
i use pathname:
$(split-path $event.sourceeventargs.fullpath)
the code add body of email using below:
$global:newfiles.add("`n[$(get-date -format hh:mm:ss)]`tnew file named $($event.sourceeventargs.name) arrived in $(split-path $event.sourceeventargs.fullpath) , copied $($dpath)\$((get-date).tostring('yyyy'))\$((get-date).tostring('mmm yyyy'))\$((get-date).adddays(1 + $(1,2 -eq 7 - [int]$formatteddate.dayofweek) ).tostring('mmm d yyyy'))")
here how email sent:
while ($watcher.enableraisingevents -or $global:newfiles.count -gt 0) { #sleep start-sleep -seconds 60 if($global:newfiles.count -gt 0) { #convert list of strings single string (multiline) $smtpbody = $global:newfiles $smtp.send($smtpfrom, $smtpto, $smtpsubject, $smtpbody) #mail sent, empty array $global:newfiles.clear() }
}
as theincorrigible1 mentioned missing html tags tell outlook hyperlinkg:
$body = "<a href='\\vavm\ftp\k nw\incoming'>\\vavm\ftp\k nw\incoming</a>" send-mailmessage -to $mailto -smtpserver $mailserver -from $mailfrom -body $mailbody -bodyashtml -subject $mailsubject
wiki
Comments
Post a Comment