Anhang von bestimmtem Sender mit bestimmten Inhalt in Ordner

  • Outlook

    Anhang von bestimmtem Sender mit bestimmten Inhalt in Ordner

    Hallo Leute,

    ich habe in outlook noch nie etwas geschrieben (habe nur Erfahrung in Excel VBA),
    jetzt möchte ich aber das Outlook ungelesene Mails abcheckt auf bestimmte Werte,
    wenn alles passt soll der Anhang in einem Ordner gespeichert werden.

    Parameter die stimmen müssen sind:
    -Sender der Email (if false then Exit)
    -Tag und Monats Zeitraum (if false then Exit)
    -hat eine PDF als Anhang (if false then Exit)


    Ich habe mir jetzt erstmal die ersten schnellen Ideen aufgeschrieben,
    aber weiß eben nicht ob es für solche Sachen bereits vordefinierte/implementierte
    Funktionen usw. in Outlook VBA gibt.

    Habt ihr Vorschläge, Ideen, oder sonstiges für mich?


    Hier mein bisschen "pseudo" Code:

    Visual Basic-Quellcode

    1. ​Option Explicit
    2. Sub Main()
    3. '//Dim fso As Object :Set fso = CreateObject("Outlook.Application")
    4. Dim oOut As Object :Set oOut = "Current outlook sesh...if not then new one.." '//Bool Funct wieder
    5. Dim oMail As Object
    6. Dim curDate As Date
    7. '//Datum der momentanen E-Mail
    8. curDate = oMail.Date
    9. '/* check a bunch of bool Functions....
    10. ' ...some more
    11. ' ...almost there
    12. '/ any mail valid?
    13. '//Then grab the attatchment from here on!
    14. '//Code..... to get attatchment and save it in user folder xy
    15. End Sub
    16. Private Function OutlookAppIsRunning() As Boolean
    17. End Function
    18. 'check the name of the sender
    19. '=================================================
    20. 'Bool Function to see if the name of sender is allowed
    21. Private Function CorrectMailName(ByVal senderName As String) As Boolean
    22. If senderName = "some Mail address..." Then CorrectMailName = True '//Email noch einfügen!
    23. End Function
    24. '1 Check if the Date is in a certain field
    25. '2 Check if the Day and the Month are in field
    26. '=================================================
    27. 'Check if day and month are OK
    28. Private Function curDateIsCorrect(ByVal DateToCheck As Date) As short
    29. if dayIsAllowed(DateToCheck) And _
    30. if monthIsAllowed(DateToCheck) Then curDateIsCorrect = True
    31. End Function
    32. 'Bool Function for Day
    33. Private Function dayIsAllowed(ByVal DayToCheck) As Boolean
    34. Dim temp As Byte
    35. temp = CByte(Format(DateToCheck, "dd")
    36. Select Case temp
    37. Case 1 to 5
    38. dayIsAllowed = True
    39. Case 26 to 31
    40. dayIsAllowed = True
    41. End Select
    42. End Function
    43. '//Bool Function ffor Month
    44. Private Function monthIsAllowed(ByVal MonthToCheck) As Boolean
    45. Dim temp As Byte
    46. Dim curMonth As Byte
    47. Dim diff As Byte
    48. curMonth = CByte(Date, "mm")
    49. temp = CByte(Format(DateToCheck, "mm")
    50. diff = curMonth - temp
    51. Select Case diff
    52. Case 1
    53. monthIsAllowed = True
    54. Case 0
    55. monthIsAllowed = True
    56. End Select
    57. End Function
    58. 'See if there is some Data to get
    59. '=================================================
    60. '//Bool for checking if the Mail has an Attachment
    61. Private Function MailHasAttachment() As Boolean
    62. '//some Code
    63. End Function