Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. Sub Email()
  2.  
  3. Dim OutApp As Object
  4. Dim OutMail As Object
  5. Dim cell As Range
  6. Dim Src As Worksheet
  7.  
  8. Application.ScreenUpdating = False
  9. Set OutApp = CreateObject("Outlook.Application")
  10. Set Src = ThisWorkbook.Sheets("List")
  11.  
  12. On Error GoTo cleanup
  13.  
  14. Src.Select
  15. For Each cell In Columns("C").Cells.SpecialCells(xlCellTypeConstants)
  16. If cell.Value Like "?*@?*.?*" Then
  17.  
  18. Set OutMail = OutApp.CreateItem(0)
  19. On Error Resume Next
  20. With OutMail
  21. .To = cell.Value
  22. .Subject = "Splunk Access"
  23. .Body = "Hi " & Cells(cell.Row, "A").Value _
  24. & vbNewLine & vbNewLine & _
  25. "I have created an account: Production." & _
  26. vbNewLine & vbNewLine & _
  27. "Your username and password for this environment is:" & _
  28. vbNewLine & vbNewLine & _
  29. "Username: " & Cells(cell.Row, "B").Value & _
  30. vbNewLine & _
  31. "Password: " & Cells(cell.Row, "E").Value & _
  32. vbNewLine & vbNewLine & _
  33. "Please log in at your earliest convenience and change your password to a more secure one. " & _
  34. vbNewLine & vbNewLine & _
  35. "You can do this by clicking on your name on the top menu and select ‘Edit Account’." & _
  36. vbNewLine & vbNewLine & _
  37. "You can use this link to get to the log in page for this environment: " & _
  38. vbNewLine & vbNewLine & _
  39. "PROD: right/en-US/account/logout " & _
  40. vbNewLine & vbNewLine & _
  41. "Many thanks and kind regards"
  42. .send
  43. End With
  44. On Error GoTo 0
  45. Set OutMail = Nothing
  46. End If
  47. Next cell
  48.  
  49. cleanup:
  50. Set OutApp = Nothing
  51. Application.ScreenUpdating = True
  52. End Sub
  53.  
  54. .send
  55.  
  56. .Display
  57. Application.Wait (Now + TimeValue("0:00:01"))
  58. Application.SendKeys "%"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement