2013-12-19 74 views
0

這可能是一個很小的東西,我想念,但我似乎無法找到問題。問題與HYPERLINK

Sub sendemail() 

'Save the form with todays date 
Application.Save Format(Now, "dd-mm-yy") & ".xls" 

'Create the email 
Dim OutApp As Object 
Dim OutMail As Object 
Dim strbody As String 

Set OutApp = CreateObject("Outlook.Application") 
Set OutMail = OutApp.CreateItem(0) 

strbody = "<HTML><BODY>" 
strbody = strbody & "<A href= http://ne-xxx.xxx.xxx.xxx.biz/ASP/SFP/BHGP/xxUK-OPS/Shared%20Documents/xxx/AllItems.aspx?RootFolder=%2fAxP%2fASP%2fBP%2fNUK%2dOPS%2fShared%20Documents%2f60%2e%20Shift%20Schedule&FolderCTID=&View=%7b1A03DBA9%2d7CEB%2d466F%2d8EA8%2dDDE03D95CDC0%7d>URL</A>" 
strbody = strbody & "</BODY></HTML>" 
On Error Resume Next 

With OutMail 
    .To = "[[email protected]]" 
    .cc = "" 
    .BCC = "" 
    .Subject = "New Holiday Request on " & Format(Now(), "dd/mm/yyyy") & " by " & Range("C2") & "" 
    .Body = strbody 
    .Send 

End With 
On Error GoTo 0 
Set OutMail = Nothing 
Set OutApp = Nothing 
Debug.Print strbody 

End Sub 

最終結果應該只是在電子郵件中的超鏈接...但它顯示:

http://ne-xxx.xxxx.xxx.xxxx.xxx/sSP/SXP/BJHJP/ xxx-OPS/Shared%20Documents/Forms/AllItems.aspx?RootFolder =%2fASP%2fSsP%2foP%2fNBXUK%2dOPS%2fShared%20Documents%2f60%2e%20Shift%20Schedule & FolderCD = & View =%7b1A03DBA9%2d7CEB%2d466F %2d8EA8%2dDDE03D95CDC0%7D> URL

+1

嘗試包裹在apostrophies網址 – Moob

+0

你需要加倍報價,href =「」http:/// ...「」 –

+0

似乎沒有工作 – user3013325

回答

1

請使用下面的代碼塊的工作

strbody = strbody & "<A href=""http://ne-xxx.xxx.xxx.xxx.biz/ASP/SFP/BHGP/xxUK-OPS/Shared%20Documents/xxx/AllItems.aspx?RootFolder=%2fAxP%2fASP%2fBP%2fNUK%2dOPS%2fShared%20Documents%2f60%2e%20Shift%20Schedule&FolderCTID=&View=%7b1A03DBA9%2d7CEB%2d466F%2d8EA8%2dDDE03D95CDC0%7d"">URL</A>"  

.HTMLBody = strbody instead of Body 
0

變化

.Body = strbody 

.HTMLBody = strbody 

我的示例VBS代碼帶或不帶引號

Set OutApp = CreateObject("Outlook.Application") 
Set OutMail = OutApp.CreateItem(0) 

strbody = "<HTML><BODY>" 
strbody = strbody & "<A href=http://ne-xxx.xxx.xxx.xxx.biz/ASP/SFP/BHGP/xxUK-OPS/Shared%20Documents/xxx/AllItems.aspx?RootFolder=%2fAxP%2fASP%2fBP%2fNUK%2dOPS%2fShared%20Documents%2f60%2e%20Shift%20Schedule&FolderCTID=&View=%7b1A03DBA9%2d7CEB%2d466F%2d8EA8%2dDDE03D95CDC0%7d>URL</A>" 
strbody = strbody & "</BODY></HTML>" 

With OutMail 
    .To = "[email protected]" 
    .HTMLBody = strbody 
    .Send 
End With 

Set OutMail = Nothing 
Set OutApp = Nothing