2017-01-09 17 views
0

私はExcelのテキストボックスからOutlook電子メールを作成するというアイデアを持っています。 問題は、電子メールが表示され、ハイパーリンクが存在しないときに、単語を書き込んでハイパーリンクを置くときです。VBAによるハイパーリンク付きのOutlook電子メールの作成

Sub Envio() 
Dim endereco, arquivo, destino, assunto, mensagem, nome, copia, anexo As String 
Dim row, report As Integer 
Dim i As Integer 
Dim OutApp As Outlook.Application 
Dim outMail As Outlook.MailItem 

anexo = ThisWorkbook.Sheets("Mensagem").Cells(39, 2).Value 
assunto = ThisWorkbook.Sheets("Mensagem").Cells(5, 2).Value 
mensagem = ThisWorkbook.Sheets("Mensagem").[TextBox].Text & vbCrLf 
copyblind = ThisWorkbook.Sheets("Mensagem").Cells(8, 2).Value 


i = 2 

destino = ThisWorkbook.Sheets("Emails").Cells(i, 1).Value 



Do Until destino = "" 
nome = ThisWorkbook.Sheets("Emails").Cells(i, 2).Value 
copia = ThisWorkbook.Sheets("Emails").Cells(i, 3).Value 


Application.DisplayAlerts = False 
Set OutApp = CreateObject("Outlook.Application") 
Set outMail = OutApp.CreateItem(olMailItem) 


With outMail 

.To = destino 
If copia <> "" Then 
.CC = copia 
Else 
.CC = "" 
End If 
.BCC = copyblind 
.Subject = nome & ", " & assunto 
.Body = mensagem 
If anexo <> "" Then 
.Attachments.Add (anexo) 
End If 
.BodyFormat = olFormatHTML 
.HTMLBody = "<BODY style=font-size:11pt;font-family:Calibri>" & mensagem & "<BR><BR>" & _ 
"</BODY>" 




.Display 

End With 

i = i + 1 
destino = ThisWorkbook.Sheets("Emails").Cells(i, 1).Value 

Set outMail = Nothing 
Set OutApp = Nothing 

Loop 

Application.DisplayAlerts = True 

End Sub 

誰かが私を助けることができますか?

+2

してください、[インデントあなたのコード](http://rubberduckvba.com/indentation)に学びます。適切なインデントは、無駄なデバッグの時間を節約することができます。 –

答えて

0

はそうのようなあなたの電子メールの本文にリンク用のHTMLタグを入れてみてください:

<a href="https://yourhyperlink.com">Your Hyperlink</a> 
+0

しかし、私はいつもハイパーリンクを変更しているので、私はこれを「ダイナミック」な方法でしたいと思っています –

+0
+0

Your Hyperlink」「 – BYates

関連する問題