VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Download Email Attachments:UPDATE

by Gemma Dobbins (2 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (7 Votes)

Updated email program. This code allows you to download multiple
attachments and copy them into a directory. The program then
replys to the author with a message or/and attachment automatically.

Inputs
MapiSession Control, MapiMessage Control, 2 command buttons, 1 text box.

Rate Download Email Attachments:UPDATE

Private Sub Command1_Click()
  MAPISession1.DownLoadMail = False
  MAPISession1.SignOn
  MAPIMessages1.SessionID = MAPISession1.SessionID
  MAPIMessages1.MsgIndex = -1
  
  MAPIMessages1.Compose
  MAPIMessages1.Send True
  
  MAPISession1.SignOff
End Sub
Private Sub Command2_Click()
  MAPISession1.NewSession = True
  MAPISession1.Action = 1 'session_signon
  MAPIMessages1.SessionID = MAPISession1.SessionID
  MAPIMessages1.FetchUnreadOnly = True
  MAPIMessages1.Action = 1 'message_fetch
     Dim i As Integer
    Text1.Text = MAPIMessages1.MsgNoteText
     For i = 0 To MAPIMessages1.AttachmentCount - 1
       MAPIMessages1.AttachmentIndex = i
       Dim intLenFileName As Integer
       Dim intStrPos As Integer
       intLenFileName = Len(MAPIMessages1.AttachmentPathName)
       For intStrPos = intLenFileName To 1 Step -1
         If InStr(1, _
             Right$(MAPIMessages1.AttachmentPathName, _
                 intLenFileName - (intStrPos - 1)), _
             "\", 1) Then
           strNewFileName = _
            Right$(MAPIMessages1.AttachmentPathName, _
                intLenFileName - intStrPos)
           Exit For
         End If
       Next
       FileCopy MAPIMessages1.AttachmentPathName, _
           "c:\" & strNewFileName
     Next
     
     Mail
     MAPIMessages1.Delete
  MAPISession1.SignOff
End Sub
Private Function Mail()
 Dim o As New Outlook.Application
 Dim m As Object
 Set m = o.CreateItem(olMailItem)
 m.To = MAPIMessages1.MsgOrigAddress
 m.Subject = "Fantastic!!!"
 m.Attachments.Add "C:\Fantastic.txt"
 m.Show ' this can be taken out if you want an automated program
 m.Send
End Function

Download this snippet    Add to My Saved Code

Download Email Attachments:UPDATE Comments

No comments have been posted about Download Email Attachments:UPDATE. Why not be the first to post a comment about Download Email Attachments:UPDATE.

Post your comment

Subject:
Message:
0/1000 characters