Hi Rajesh,
Please find the full working code of your project.
Open your file and saveas .xlsm format. Insert a module and paste the code. Also update the references - Add Microsoft Outlook items and the signature location in the code below at 'Change this string - according to your system setup - c: or D:
_______________________________________________________
Public to_list As String
Public cc_list As String
Sub to_cc_list()
For i = 3 To wksEList.Range("C1000").End(xlUp).Row
If wksEList.Range("C" & i) <> "" Then
to_list = to_list & wksEList.Range("C" & i) & "; "
End If
Next
For i = 2 To wksEList.Range("d1000").End(xlUp).Row
If wksEList.Range("d" & i) <> "" Then
cc_list = cc_list & wksEList.Range("d" & i) & "; "
End If
Next
End Sub
Sub send_mail()
Dim olApp As Object ' Outlook.Application
Dim Msg As Object ' Outlook.MailItem
to_cc_list
Set olApp = GetOutlookApp
If olApp Is Nothing Then GoTo ProgramExit
'Change this string - according to your system setup - c: or D:
SigString = "D:\Documents and Settings\" & Environ("username") & "\Application Data\Microsoft\Signatures\test.txt"
Signature = GetBoiler(SigString)
For i = 6 To wksRawdata.UsedRange.Rows.Count
If wksRawdata.Range("n" & i) = 0 Then
subject = "Serial Number " & wksRawdata.Range("a" & i) & " is Waiting for the Approval"
Content = ThisWorkbook.FullName & Chr(10) & Signature
Set Msg = olApp.CreateItem(olMailItem)
With Msg
.To = to_list
.CC = cc_list
.Body = Content
.subject = subject
.display
.send
End With
End If
Next
ProgramExit:
Exit Sub
ErrorHandler:
MsgBox Err.Number & " - " & Err.Description
Resume ProgramExit
End Sub
Function GetOutlookApp() As Object
On Error Resume Next
Set GetOutlookApp = GetObject(, "Outlook.Application")
If Err.Number <> 0 Then
Set GetOutlookApp = CreateObject("Outlook.Application")
End If
On Error GoTo 0
End Function
Function GetBoiler(ByVal sFile As String) As String
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
_______________________
_______________________________
Enjoy maadi.
Regards,
Lokesh
Moderator Note:
Pls use code tags around your code next time as per forum rules.
Bookmarks