ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Outlook mail from Excel (https://www.excelbanter.com/excel-programming/374624-outlook-mail-excel.html)

Tufail

Outlook mail from Excel
 
Hi,
someone can help me, now i am using follow code for outlook mail, next i
want use this code with selected range like C1:E50 (but in this code i don't
want use--Bonus = Format(cell.Offset(0, 1).Value, "$0,000."), i still want
use cell A=customer name & cell B=maill address where i want send mails and
range would be C1:E50
hope you could understand
-------------------------------------------------------------
Sub SendEmail()
Dim cell As Range
Dim Subj As String
Dim EmailAddr As String
Dim Recipient As String
Dim Bonus As String
Dim Msg As String
Dim HLink As String
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstant s)
If cell.Value Like "*@*" Then
'Get the data
Subj = "Your Annual Bonus"
Recipient = cell.Offset(0, -1).Value
EmailAddr = cell.Value
Bonus = Format(cell.Offset(0, 1).Value, "$0,000.")


'Compose message
Msg = "Dear " & Recipient & "%0A"
Msg = Msg & "%0A" & "I am pleased to inform you that your annual bonus
is "
Msg = Msg & Bonus & "%0A"
Msg = Msg & "%0A" & "Lubna Tufail"
Msg = Msg & "%0A" & "President"

'Build hyperlink
HLink = "mailto:" & EmailAddr & "?"
HLink = HLink & "subject=" & Subj & "&"
HLink = HLink & "body=" & Msg
'Send it
ActiveWorkbook.FollowHyperlink HLink
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys "%s", True
End If
Next
End Sub

----------------------------------------------------------------


All times are GMT +1. The time now is 09:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com