2017-08-13 48 views
0

HTML表我想創建該表和循環創造了行使用VBA的電子郵件模板:創建VBA

<td width=254 nowrap style='width:190.75pt;border:none;border-bottom:solid white 1.0pt;background:#BDD7EE;padding:0in 5.4pt 0in 5.4pt;height:16.5pt'><p class=MsoNormal align=center style='text-align:center'><b><span style='font-family:"Times New Roman",serif;color:black'>&nbsp;<o:p></o:p></span></b></p></td></tr></table> 

我想:

FullString = "<td width=254 nowrap style='width:190.75pt;border:none;border-bottom:solid white 1.0pt;background:#BDD7EE;padding:0in 5.4pt 0in 5.4pt;height:16.5pt'><p class=MsoNormal align=center style='text-align:center'><b><span style='font-family:""&""Times New Roman""&"",serif;color:black'>FirstName<o:p></o:p></span></b></p></td></tr></table>" 

ReplaceWith = "<td width=254 nowrap style='width:190.75pt;border:none;border-bottom:solid white 1.0pt;background:#BDD7EE;padding:0in 5.4pt 0in 5.4pt;height:16.5pt'><p class=MsoNormal align=center style='text-align:center'><b><span style='font-family:""&""Times New Roman""&"",serif;color:black'>James<o:p></o:p></span></b></p></td></tr><td width=254 nowrap style='width:190.75pt;border:none;border-bottom:solid white 1.0pt;background:#BDD7EE;padding:0in 5.4pt 0in 5.4pt;height:16.5pt'><p class=MsoNormal align=center style='text-align:center'><b><span style='font-family:""&""Times New Roman""&"",serif;color:black'>FirstNameReplace<o:p></o:p></span></b></p></td></tr></table>" 

oTemplate.HTMLBody = Replace(oTemplate.HTMLBody, FullString, ReplaceWith) 

沒有被換下。

+0

插入表格對象插入到郵件正文 – jsotola

回答

0

我thnk你可以按照這個公式來代替

.HTMLBody = Replace(.HTMLBody, "#recipient#", "Some other value")

more 1

more 2

+0

我之所以這樣做,我做的方法是因爲如果客戶不止一個,我將循環重新創建要替換的關鍵字。該表包含我需要的樣式,因此該行將被重新創建。 –

+0

hii是這個幫助https://stackoverflow.com/questions/41886251/dynamically-create-html-table-rows-with-vba –

+0

不是真的,因爲我有我自己的電子郵件模板,我打算使用。我只需要知道我將如何添加額外的行。 –