简体   繁体   English

从带有 Excel 的文本单元格发送具有指定粗体/大小/颜色/下划线文本格式的 Email VBA

[英]Send Email With Specified Bold/Size/Color/Underline Text Format from a Text Cell with Excel VBA

I'm trying to send an Outlook e-mail, changing the text format for specific text from a specific cell in Excel.我正在尝试发送一封 Outlook 电子邮件,更改 Excel 中特定单元格中特定文本的文本格式。

For example, in my worksheet there's a cell with text "Jorge Bailey" and I want to edit it from "Jorge Bailey" to Jorge Bailey .例如,在我的工作表中有一个包含文本“Jorge Bailey”的单元格,我想将其从“Jorge Bailey”编辑为Jorge Bailey

Sub enviar_email_gestor_maquina()

Set objeto_outlook = CreateObject("Outlook.Application")

Set Email = objeto_outlook.createitem(0)

Email.display

Email.to = "jorge.bailey@syngenta.com"

Email.Subject = "Seu Notebook esta Elegível a Troca - Renovação Tecnológica"
       
Link = "<span style=""font-family:Arial; font-size: 12pt; ""<a href=""https://app.smartsheet.com/b/form/3976fc184fc84380a68d0da69b8ddc6d"" >Link Formulário</a>"
   
txt1 = "<span style=""font-family:Arial; font-weight:bold; color: #808000; font-size:20pt;"">Renovação Tecnológica - Troca de notebook</span>" & "<br><br>"
 
txt2 = "<span style=""font-family:Arial; font-size: 15pt;""> & Range(B5) & </span>"

Email.htmlbody = txt1 & htmltxt2 & Link & Email.htmlbody
Email.Recipients.ResolveAll

End Sub

What is wrong with "txt2"?** “txt2”有什么问题?**

What about Hyperlinks?超链接呢?

I would like to do it with HYPERLINKS, because when you put a link from a cell in your e-mail body, the VBA gets the text and not the hyperlink.我想用 HYPERLINKS 来实现,因为当您在电子邮件正文中放置一个单元格中的链接时,VBA 获取的是文本而不是超链接。

You quoting is incorrect:你引用不正确:

Set objeto_outlook = CreateObject("Outlook.Application")

Set Email = objeto_outlook.createitem(0)

Email.display

Email.to = "jorge.bailey@syngenta.com"

Email.Subject = "Seu Notebook esta Elegível a Troca - Renovação Tecnológica"
       
txt1 = "<span style='font-family:Arial; font-weight:bold; color: #808000; font-size:20pt;'>" & _
         "Renovação Tecnológica - Troca de notebook</span><br><br>"
 
txt2 = "<span style='font-family:Arial; font-size: 15pt;'><b>" & Range("B5").Value & "</b></span>"
 
Link = "<span style='font-family:Arial; font-size: 12pt;'>" & _
   "<a href='https://app.smartsheet.com/b/form/3976fc184fc84380a68d0da69b8ddc6d'>Link Formulário</a></span>"

Email.htmlbody = txt1 & txt2 & Link & Email.htmlbody
Email.Recipients.ResolveAll

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM