Top What's New Develop Technic Contact
ƒƒ“ƒ|ƒCƒ“ƒg

[VBA]

Access‚©‚çOutLook‚ðƒRƒ“ƒgƒ[ƒ‹‚·‚é

[“®ìŠÂ‹«]

Microsoft Windows 2000
Microsoft Access 2000
Microsoft OutLook 2000

[ŠT—v]

Access‚̃tƒH[ƒ€ã‚©‚çOutLook‚ð‹N“®‚µAƒ[ƒ‹‚Ì‘—ŽóM‚Ȃǂ̃Rƒ“ƒgƒ[ƒ‹‚ªs‚¦‚Ü‚·B‚È‚¨‚±‚±‚ŏЉ‚é‚̂́AOutLook‚Ì‘—MƒgƒŒƒC‚Öƒ[ƒ‹‚ð‘—‚é•û–@‚ƁAŽóMƒgƒŒƒC‚̐V’…ƒ[ƒ‹‚ðŠm”F‚·‚é•û–@‚Å‚·BŽÀÛ‚É‘—ŽóM‚·‚é‚É‚ÍOutLook‘¤‚Å‚Ì’èŠú“I‚È‘—ŽóM‚Ȃǂ̐ݒ肪•K—v‚É‚È‚è‚Ü‚·B

[Žè‡]

1: •Ï”éŒ¾

Access‚ŐV‹KƒtƒH[ƒ€‚ðì¬‚µAƒ‚ƒWƒ…[ƒ‹ƒŒƒxƒ‹‚ʼnº‹L‚̃R[ƒh‚ð‹Lq‚µ‚ĉº‚³‚¢B

Dim m_OLApp As Object
Dim m_Namespace As Object
Dim m_Folder As Object
Dim m_Item As Object
Dim m_RecvItem As Object
	

2F OutLook‹N“®

Access‚̃tƒH[ƒ€ƒI[ƒvƒ“‚̃Cƒxƒ“ƒgƒvƒƒV[ƒWƒƒ‚ɉº‹L‚̃R[ƒh‚ð‹Lq‚µ‚ĉº‚³‚¢B

'outlook‚Ì‹N“®
Set m_OLApp = CreateObject("Outlook.Application")
Set m_Namespace = m_OLApp.GetNamespace("MAPI")
Set m_Folder = m_Namespace.GetDefaultFolder(6)
m_Folder.Display
      

3F ‘—MƒgƒŒƒC‚Ƀ[ƒ‹‚ð‘—‚é

ƒtƒH[ƒ€ã‚ɃRƒ}ƒ“ƒhƒ{ƒ^ƒ“‚ðì¬‚µAƒNƒŠƒbƒN‚̃Cƒxƒ“ƒgƒvƒƒV[ƒWƒƒ‚ɉº‹L‚̃R[ƒh‚ð‹Lq‚µ‚ĉº‚³‚¢B

'ƒ[ƒ‹ì¬
Set l_Item = m_OLApp.CreateItem(olMailItem)
l_Item.To = "xxx@xxx.xx.xx"	'‘—MæƒAƒhƒŒƒX
l_Item.Subject = "ƒeƒXƒg"		'Œ–¼
l_Item.Body = "‘—‚ê‚Ü‚µ‚½‚©H" 	'–{•¶
l_Item.send 	  
	  

‚Ü‚½ l_Item.send ‚Ì‘O‚É

l_Item.Display

‚ƉÁ‚¦‚é‚ƃ[ƒ‹V‹Kì¬ƒ_ƒCƒAƒƒO‚ªŒ»‚ê‚Ü‚·B

4F ŽóMƒgƒŒƒC‚̃[ƒ‹‚ðŒ©‚é

ƒRƒ}ƒ“ƒhƒ{ƒ^ƒ“‚ðì¬‚µAƒNƒŠƒbƒNƒCƒxƒ“ƒgƒvƒƒV[ƒWƒƒ‚ɉº‹L‚̃R[ƒh‚ð‹Lq‚µ‚ĉº‚³‚¢B

Dim l_unread As Integer '–¢ŠJ••”
Dim l_cnt As Integer '‘SŽóMƒ[ƒ‹”
Dim m As Integer 'ƒJƒEƒ“ƒg—pƒ[ƒ‹‘”
Dim i As Integer '–¢“ǃ[ƒ‹ƒJƒEƒ“ƒg—p

l_unread = m_Folder.UnReadItemCount '–¢ŠJ••ƒ[ƒ‹”
l_cnt = m_Folder.Items.Count 'ƒ[ƒ‹‘”

If l_unread <> 0 Then '–¢“ǃ[ƒ‹‚ª‚ ‚é‚Æ‚«

   ReDim act(l_unread) As Variant 'ˆ¶æ
   ReDim frm(l_unread) As Variant '‘—MŽÒƒAƒhƒŒƒX
   ReDim sday(l_unread) As Variant 'ƒ[ƒ‹‘—M“úŽž
   ReDim rday(l_unread) As Variant 'ƒ[ƒ‹ŽóM“úŽž
   ReDim sbj(l_unread) As Variant 'ƒ[ƒ‹ƒ^ƒCƒgƒ‹
   ReDim msg(l_unread) As Variant 'ƒ[ƒ‹–{•¶
 
    i = 1 '–¢“ǃ[ƒ‹‰Šú’l

   'ƒ[ƒ‹‚ðˆêŒ–Ú‚©‚猩‚Ä‚¢‚­
   For m = 1 To l_cnt 

      Set m_Item = m_Folder.Items(m) 'ƒ[ƒ‹ŠJ‚­

      If m_Item.unread = True Then '–¢ŠJ••‚̃[ƒ‹‚¾‚¯‚ðŠJ‚­
         act(i) = m_Item.To'ˆ¶æ
         Set m_RecvItem = m_Item.Reply 'ˆê“x•ÔM‚µ‚ăAƒhƒŒƒX‚ðŽæ‚èo‚·B
         frm(i) = m_RecvItem.Recipients(1).address 'ƒ[ƒ‹‘—MŽÒƒAƒhƒŒƒX
         sday(i) = m_Item.senton 'ƒ[ƒ‹‘—M“úŽž
         rday(i) = m_Item.ReceivedTime 'ƒ[ƒ‹ŽóM“úŽž
         sbj(i) = m_Item.Subject 'ƒ[ƒ‹ƒTƒuƒWƒFƒNƒg
         msg(i) = m_Item.Body 'ƒ[ƒ‹–{•¶
         'ƒ[ƒ‹‚ðŠJ••‚·‚é (‚±‚̏ˆ—‚ð‚µ‚È‚¢‚ƁA
         'ƒf[ƒ^‚ðŽæ‚èo‚µ‚Ä‚à–¢“Ǐó‘Ô‚Ì‚Ü‚Ü‚É‚È‚é)
         m_Folder.Items(m).unread = False

         MsgBox "ˆ¶æ:" & act(i) & vbNewLine & _
               "‘—MŽÒƒAƒhƒŒƒX:" & frm(i) & vbNewLine & _
               "‘—M“úŽž:" & sday(i) & vbNewLine & _
               "ŽóM“úŽž:" & rday(i) & vbNewLine & _
               "ƒTƒuƒWƒFƒNƒg:" & sbj(i) & vbNewLine & _
               "–{•¶:" & msg(i)
               i = i + 1
      End If
   Next
End If 	  
	  

‚Ü‚¸Aƒ[ƒ‹‘”i–¢“ǁ{Šù“ǁj‚Æ–¢“ǃ[ƒ‹Œ”‚ðŽæ“¾‚µ‚Ü‚·B–¢“ǃ[ƒ‹”•ª‚̕ϐ”‚ð’è‹`‚µ‚āA‘Sƒ[ƒ‹‚ðŠù“ǁE–¢“Ç‚Å”»’f‚µA–¢“Ç‚Å‚ ‚ê‚΂»‚Ì“à—e‚ð•Ï”‚ɃZƒbƒg‚µ‚Ä‚¢‚«‚Ü‚·B

5F OutLook‚̏I—¹

ƒtƒH[ƒ€‚̃Nƒ[ƒYƒCƒxƒ“ƒgƒvƒƒV[ƒWƒƒ‚ɉº‹L‚̃R[ƒh‚ð‹Lq‚µ‚ĉº‚³‚¢B

'outlook‚̏I—¹
m_OLApp.Quit

'ƒIƒuƒWƒFƒNƒg‚ÌŠJ•ú
Set m_OLApp = Nothing
Set m_Namespace = Nothing
Set m_Folder = Nothing
Set m_Item = Nothing 	  
	  

@