SHARE
TWEET

Untitled

a guest Dec 14th, 2019 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub GetFromOutlook()
  2.  
  3. Dim OutlookApp As Outlook.Application
  4. Dim OutlookNamespace As Namespace
  5. Dim Folder As MAPIFolder
  6. Dim OutlookMail As Variant
  7. Dim i As Integer
  8.  
  9. Set OutlookApp = New Outlook.Application
  10. Set OutlookNamespace = OutlookApp.GetNamespace(“MAPI”)
  11. Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox).Folders(“impMail”)
  12.  
  13. i = 1
  14.  
  15. For Each OutlookMail In Folder.Items
  16. If OutlookMail.ReceivedTime >= Range(“email_Receipt_Date”).Value Then
  17.  
  18. Range(“email_Subject”).Offset(i, 0).Value = OutlookMail.Subject
  19. Range(“email_Subject”).Offset(i, 0).Columns.AutoFit
  20. Range(“email_Subject”).Offset(i, 0).VerticalAlignment = xlTop
  21. Range(“email_Date”).Offset(i, 0).Value = OutlookMail.ReceivedTime
  22. Range(“email_Date”).Offset(i, 0).Columns.AutoFit
  23. Range(“email_Date”).Offset(i, 0).VerticalAlignment = xlTop
  24. Range(“email_Sender”).Offset(i, 0).Value = OutlookMail.SenderName
  25. Range(“email_Sender”).Offset(i, 0).Columns.AutoFit
  26. Range(“email_Sender”).Offset(i, 0).VerticalAlignment = xlTop
  27. Range(“email_Body”).Offset(i, 0).Value = OutlookMail.Body
  28. Range(“email_Body”).Offset(i, 0).Columns.AutoFit
  29. Range(“email_Body”).Offset(i, 0).VerticalAlignment = xlTop
  30.  
  31. i = i + 1
  32. End If
  33. Next OutlookMail
  34.  
  35. Set Folder = Nothing
  36. Set OutlookNamespace = Nothing
  37. Set OutlookApp = Nothing
  38.  
  39. End Sub
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top