Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT
Private Sub Cmd_Yes_TEST_emails_Click() Dim Last_Row_No As Long Dim i As Long Dim Next_Email_address As String Dim Next_First_Name As String Dim Doc_To_Open As String Dim Full_Doc_Name As String Dim Mail_Body As Variant Dim wrdApp As Word.Application Dim wrdDoc As Word.Document Dim oEmail As MailItem Set olApp = New Outlook.Application Set olNs = olApp.GetNamespace("MAPI") Call Set_Up_Files Call Set_Up_Ranges Userform1.Hide Doc_To_Open = Sheets("Front Sheet").ComboBox2.Value Last_Row_No = Sheets("Test E-mails").Range("C6").End(xlDown).Row 'Invoke the word object Set wrdApp = CreateObject("Word.Application") wrdApp.Visible = True 'Determine which document is required Full_Doc_Name = Workbook_Path & "\" & Doc_To_Open & ".doc" Set wrdDoc = wrdApp.Documents.Open(Full_Doc_Name) 'Turn of screen alerts Application.DisplayAlerts = False 'Save the word file as a HTML document wrdDoc.SaveAs Filename:="HTMLDoc.html", FileFormat:=wdFormatHTML 'Get the mail body Mail_Body = wrdDoc.HTMLProject.HTMLProjectItems(1).Text 'Create the Outlook mail For i = 6 To Last_Row_No Set oEmail = olApp.CreateItem(olMailItem) Next_Email_address = Sheets("Test E-mails").Range("C" & i).Value Next_First_Name = Sheets("Test E-mails").Range("B" & i).Value With oEmail .To = Next_Email_address .Subject = "Document.doc" .HTMLBody = Mail_Body .Send End With Next i MsgBox " Your e-mails have been sent" Set olApp = Nothing Set olNs = Nothing Set oEmail = Nothing Set wrdDoc = Nothing Set wrdApp = Nothing End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.