Hi Experts
I have created a macro in excel which sends the email via outlook to more than user at a point of time. The macro is working fine when I add plain text in the cell, which I am using for the body of the mail. The issue is when I am trying to add the table field in this cell. It won't accept the table and consider it a text and paste it in the body of the outlook as a plain text instead of table. I tried many options but fail to get through it.
The code I am using is mentioned below
I want the msg code below to accept the following content in the cell E
Dear Sir ,
We would like to wish you a Merry chirtmas & Happy New Year.
[TABLE="width: 500"]
<TBODY>[TR]
[TD]Ref[/TD]
[TD]Ccy[/TD]
[TD]Amount[/TD]
[TD]Name[/TD]
[TD]DueDate[/TD]
[/TR]
[TR]
[TD]133456F12[/TD]
[TD]INR[/TD]
[TD]1,084.00[/TD]
[TD]ABC Company[/TD]
[TD]15/10/2014[/TD]
[/TR]
</TBODY>[/TABLE]
Regards,
Jagdev
I have created a macro in excel which sends the email via outlook to more than user at a point of time. The macro is working fine when I add plain text in the cell, which I am using for the body of the mail. The issue is when I am trying to add the table field in this cell. It won't accept the table and consider it a text and paste it in the body of the outlook as a plain text instead of table. I tried many options but fail to get through it.
The code I am using is mentioned below
I want the msg code below to accept the following content in the cell E
Dear Sir ,
We would like to wish you a Merry chirtmas & Happy New Year.
[TABLE="width: 500"]
<TBODY>[TR]
[TD]Ref[/TD]
[TD]Ccy[/TD]
[TD]Amount[/TD]
[TD]Name[/TD]
[TD]DueDate[/TD]
[/TR]
[TR]
[TD]133456F12[/TD]
[TD]INR[/TD]
[TD]1,084.00[/TD]
[TD]ABC Company[/TD]
[TD]15/10/2014[/TD]
[/TR]
</TBODY>[/TABLE]
Regards,
Jagdev
Code:
Sub Preview()
I = Cells(2, "B").Value ' dynamising startrownumber to user fed value at cell B2
Do ' start the action
Subj = Cells(I, "A").Value
Filepath = Cells(I, "B").Value
EmailTo = Cells(I, "C").Value
CCto = Cells(I, "D").Value
msg = Cells(I, "E").Value
Application.DisplayAlerts = False ' hey macro ,i dont wanna make you take time ,so this command to save time to avoid displays
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = EmailTo
.CC = CCto
.BCC = ""
.Subject = Subj
.body = msg
.Attachments.Add Filepath
.display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Application.DisplayAlerts = True
I = I + 1
Cells(1, "A").Value = "Outlook sent Time,Dynamic msg preview count =" & I - 3
Loop Until Cells(I, "C").Value = ""
End Sub