Use Outlook in VBA

Nay Min Naung

New member
Local time
Today, 13:56
Joined
Nov 7, 2012
Messages
6
Dear,
I am using outlook to send/receive mail. That is OK but I want to know that who send me mail(from: name of sender mail). Please tell me if you already know.
:)
Nay Min Naung
 
please show some code or where you want to do this. Or please explain how this happens. For example do you want to be forever checking for new mail?
 
Dim oApp As Outlook.Application
Dim oMsg As Object
Dim oItem As Items
Dim oFolder As Object
Dim ItemCount As Integer
Dim i As Integer
Dim mitem As MailItem
Set oApp = New Outlook.Application
Set oNS = oApp.GetNamespace("MAPI")
'Set folder to check the INBOX
Set oFolder = oNS.GetDefaultFolder(olFolderInbox)

For Each oMsg In oFolder.Items
If oMsg.Subject = Me.Subject Then
ItemCount = oMsg.Attachments.Count
If ItemCount > 0 Then
For i = 1 To ItemCount
oMsg.Attachments.Item(i).SaveAsFile XMLGeneratePath & "\" _
& oMsg.Attachments.Item(i).DisplayName
Next i

End If
If oMsg.UnRead Then
oMsg.UnRead = False
End If
End If
'' I want to get from sent mail'''
''What command how can i use?"
Next


Thank you.
Nay Min Naung
 
On the oMsg you can also do oMsg.SenderName and oMsg.SenderEmailAddress.
 
Thanks darbid,
I write your code "oMsg.SenderName and oMsg.SenderEmailAddress" in vba. That is OK, but the message security box is appear "Yes, No, Help" button. How can I do the message box is not appear? Please tell me if you know. Thank you for your reply.
Nay Min Naung
 
Thats great you solved this problem.

The Security issue is not new and if you do a quick search here and or in Google you will see many things on this topic.
 
Dear access-programmers,
I want to add new email account to outlook 2010 by using (via) Microsoft Office Access coding. So, how can I do? Please help me.
Nay Min Naung
 

Users who are viewing this thread

Back
Top Bottom