Announcement

Collapse
No announcement yet.

Automatic Outlook Mailing...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Automatic Outlook Mailing...

    Hello...

    I have been wondering about how these "viruses" get access to your Outlook address book and email them selves to all those people. The reason I'm wondering is because I think it would be really handy to intigrate my application with the Outlook address book. We receive files from our geologists via the internet and we would like to be able to automaticly forward those files to our clients. Currently cell phone technology doesn't permit us to just send emails from "the field" because the connections are so weak. I have already developed TCP/IP routines that send data and resume uploads to our server. Being that our server is on a DSL connection we have no problems with connections on that end.

    Does anybody know what SDK/API should I look into for this functionality?

    Cheers!


    -------------
    Cheers

  • #2
    Using Visual Basic and Outlook 2000 you would do something like this:

    Code:
    '// Fetch the folder names like this
    Public Sub FillFolderList()
    On Error GoTo errhandle3
    Dim z As Long
    Dim sA As String
    Dim sB As String
    Dim oApp As Outlook.Application
    Dim oNameSpace As NameSpace
    Dim oFolder As MAPIFolder
    Dim oFolder2 As Object
    Set oApp = New Outlook.Application
    Set oNameSpace = oApp.GetNamespace("MAPI")
    Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
       '//
       z = 1
       booActiveFolder(z) = True
       g_FolderName(z) = oFolder.Name
       '//
       For Each oFolder2 In oFolder.Folders
          z = z + 1
          If z <= 34 Then
             booActiveFolder(z) = True
             g_FolderName(z) = oFolder2.Name
          End If
       Next oFolder2
       '//
    Set oFolder = Nothing
    Set oNameSpace = Nothing
    Set oApp = Nothing
       '//
       For z = 1 To 34
          If booActiveFolder(z) Then
             sA = "GrabFolder::" & Trim$(g_FolderName(z)) & "="
             loadINI sA, sB
             If sB = "1" Then
                booScan(z) = True
             Else
                booScan(z) = False
                If sB <> "0" Then
                   sB = "1"
                   storeINI sA, sB
                   booScan(z) = True
                End If
             End If
          End If
       Next z
       Exit Sub
    errhandle3:
       sA = "Error: Can not find Microsoft Outlook 2000" & Chr$(13) & Chr$(10)
       sA = sA & "This program will only work on systems that have Outlook 2000" & Chr$(13) & Chr$(10)
       sA = sA & "installed. Outlook Express will **NOT** work." & Chr$(13) & Chr$(10)
       MsgBox sA
    End Sub
    
    '// After we know the folder names and select the ones that we wish to scan we can do this to grab and save the files:
    
    Public Sub ScanForFiles()
    On Error GoTo errhandle
    Dim oApp As Outlook.Application
    Dim oNameSpace As NameSpace
    Dim oFolder As MAPIFolder
    Dim oFolder2 As Object
    Dim oMailItem As Object
    Dim sMessage As String
    Dim datTime As Date
    Dim datNow As Date
    Dim sI As String
    Dim v As Long
    Dim sA As String
    Dim i As Long
    Dim sTempFile As String
    Set oApp = New Outlook.Application
    Set oNameSpace = oApp.GetNamespace("MAPI")
    Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
       frmGrab.cmdGo.Enabled = False
       sTempFile = exepath & "~7356TRN.TMP"
       If Len(Dir$(sTempFile)) > 0 Then Kill sTempFile
       datNow = Now
       sI = "d"
       For Each oFolder2 In oFolder.Folders
          '// Is this a folder that we wish to scan? //
          If IsScanFolder(oFolder2.Name) Then
             frmGrab.lblFolder.Caption = "Folder: " & oFolder2.Name
             For Each oMailItem In oFolder2.Items
                With oMailItem
                   If oMailItem.Attachments.Count > 0 Then
                      datTime = oMailItem.ReceivedTime
                      '// We are only going to get files that
                      '// are 8 days old and newer
                      v = DateDiff(sI, datTime, datNow)
                      If v <= 8 Then
                         For i = 1 To oMailItem.Attachments.Count
                            oMailItem.Attachments.Item(1).SaveAsFile sTempFile
                            sA = oMailItem.Subject
                            ProcessFile sTempFile, datTime, sA
                            If Len(Dir$(sTempFile)) > 0 Then Kill sTempFile
                         Next i
                      End If
                   End If
                End With
             Next oMailItem
          End If
       Next oFolder2
       '////////
       If IsScanFolder(oFolder.Name) Then
          frmGrab.lblFolder.Caption = "Folder: " & oFolder.Name
          For Each oMailItem In oFolder.Items
             With oMailItem
                If oMailItem.Attachments.Count > 0 Then
                   datTime = oMailItem.ReceivedTime
                   v = DateDiff(sI, datTime, datNow)
                   If v <= 8 Then
                      For i = 1 To oMailItem.Attachments.Count
                         oMailItem.Attachments.Item(1).SaveAsFile sTempFile
                         sA = oMailItem.Subject
                         '// The ProcessFile sub does something with
                         '// the file like rename and save it or    discard it
                         ProcessFile sTempFile, datTime, sA
                         If Len(Dir$(sTempFile)) > 0 Then Kill sTempFile
                      Next i
                   End If
                End If
             End With
          Next oMailItem
       End If
       '//
    Set oMailItem = Nothing
    Set oFolder = Nothing
    Set oNameSpace = Nothing
    Set oApp = Nothing
       KillOldFiles
       frmGrab.cmdGo.Enabled = True
       frmGrab.lblFolder.Caption = "ALL DONE"
       frmGrab.lblStat.Caption = ""
       Exit Sub
    errhandle:
       sA = "Error: Can not find Microsoft Outlook 2000" & Chr$(13) & Chr$(10)
       sA = sA & "This program will only work on systems that have Outlook 2000" & Chr$(13) & Chr$(10)
       sA = sA & "installed. Outlook Express will **NOT** work." & Chr$(13) & Chr$(10)
       MsgBox sA
    End Sub
    Email me at [email protected] and I would be happy to email you the complete source code to a working program that grabs files from Outlook 2000. It can be easily redone to do what you want.

    The above code is from a program that grabs incoming play by email game turn files and automatically processes them, the player's next game move is automatically emailed out to the players. Very simular to your goal.

    Converting it to a PB Program might be possible using a 3rd party addon that handles objects, but I think it might be very tricky.

    Tim Wisseman

    ------------------

    Comment


    • #3
      Just to be 100% clear.

      Are you looking for a way to read your outlook address book and forward the addresses to PB, or are you looking for a way to process files attached to incoming mail recieved by outlook?

      Tim Wisseman

      ------------------

      Comment


      • #4
        Hello Tim,

        What I would like to do is get what ever email address(es) out of my Outlook Addressbook and also email an attachment to them. In my address book I have folders which are named after well numbers, each of these folders has an email address of that wells owner. The well data files received by the server are named "[wellnumber].zip". This well number is used to determine what email address to mail the well data to. I would like to use the functionality of Outlook and it's address book to automate the emailing process...

        I hope that made sense?

        Cheers!


        ------------------
        Cheers

        Comment


        • #5
          The code I posted grabs the files from outlook, so that is not what you are after. You just want the addresses.

          Here is a link to some sample VB code that grabs all the addresses from the outlook address book.
          http://www.ostrosoft.com/vb/projects/outlook.html

          When you grab the address you should also store the name of the folder it was in so that you can match that folder name up with the well number.

          Tim


          ------------------

          Comment

          Working...
          X