ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

Excel VBA¼g¤@­Óªþ¥[Àɮרì¶l¥óªºµ{¦¡°ÝÃD

Excel VBA¼g¤@­Óªþ¥[Àɮרì¶l¥óªºµ{¦¡°ÝÃD

¦U¦ì«e½ú¡G
¦b³oÃä¤S­n¨Ó½Ð±Ð¤j®a¤F¡A¤p§Ì§Ú¦bExcel VBA¸Ì­±¼g¤F¤@­ÓFunctionªº¥D­n¥\¯à¥Î¨Ó±N«ü©wªºÀÉ®×¥[¤J¶l¥ó¤¤¡A¤§«e¤@ª½°õ¦æªº«Ü¶¶§Q¡A³Ìªñµo²{¡A§Ú¥u­nªþ¥[ªºÀÉ®×2µ§¥H¤W¡A¦Ó¥B¦³¥]¬A¤@­Ó.msgªºoutlook¶l¥óÀÉ¡A¥[®×§¹¦¨«á¡A¸Ó¶l¥óÀÉ¥´¶}³£¬OªÅ¥Õ¡A­n¬O¥u¥[³æµ§ªº¶l¥óÀɮ׫h¯à«Ü¥¿±`¶}±Ò¡A§Ú¸Õ¹L¤F«Ü¦h¦¸¡A¤£ºÞ¬O¥ý¥[¶l¥óÀÉ¡A³Ì«á¤~¥[¶l¥ó®×¡A¥u­n¬O¤Gµ§¥H¤W°£¤F¶l¥óÀÉ¥H¥~ªº¥t¤@ºØÃþ«¬ÀɮסA´N·|µo¥Í¶l¥óÀÉ¥´¶}·|¬OªÅ¥Õ¡A¦U¦ì«e«D¯à§_¦³¦nªº¸Ñ¨M¤èªk©O¡A§Úpo¥X§Úªºµ{¦¡¡A½Ð¤j®aÀ°§Ú¬Ý¬Ý¬O¤£¬O§Ú¼gªº¦³¤°»ò°ÝÃD¡A·P®¦¡C

Function Add_Attachments_File(My_MailItem As Outlook.MailItem, Add_File_Path As String, Add_File_Name As String) As Boolean
   
    Dim My_Attachments As Outlook.Attachments
    Dim My_FileSystem As Object
    Dim File_State As Boolean
    Dim File_Path As String
    Dim File_Name As String
    Dim File_FullName As String
   
    File_Path = Add_File_Path
    File_Name = Add_File_Name
   
    Correct_Path_Name File_Path, File_Name, File_FullName
    '¤W¦C°Æµ{¦¡¡A¥u¬O±N¥N¤Jªº¸ô®|»PÀɦW§@¤@­Ó¾ã²z¡A¨Ã¦X¨Ö¥X§¹¾ã¸ô®|
    Set My_FileSystem = CreateObject("Scripting.FileSystemObject")
    Set My_Attachments = My_MailItem.Attachments
   
    File_State = Check_Appoint_File(File_Path, File_Name, True)
    '¤W¦C¬O¥u³æ¯ÂÀËÅç¸ÓÀɮ׬O§_¦³¯u¹ê¦s¦b

    If File_State Then
        
        If StrComp(My_FileSystem.GetExtensionName(File_FullName), "msg", vbTextCompare) = 0 Then
            '¥Ø«e§Ú­Ì¥u¦³OutlookªºÀÉ®×­n¯S§O³]©wOlAttachmentType¬°olEmbeddeditem
            My_Attachments.Add File_FullName, olEmbeddeditem
            
        Else
            '¨ä¥¦Àɮ׮榡³£³]©wOlAttachmentType¬°olByValue
            My_Attachments.Add File_FullName, olByValue
            
        End If
        
        Add_Attachments_File = True
        
    Else
   
        Add_Attachments_File = False
                       
    End If
   
Exit_Function:
   
    Set My_Attachments = Nothing
    Set My_FileSystem = Nothing

End Function
clio

¤£¦n·N«ä¡A¦U¦ì«e½ú¡A§Ú§ä¨ìµª®×¤F¡A«á¨Ó§Ú¸Õ¤F¡A§â©I¥s³o­ÓFunctionªº¶¶§Ç§ï¤@¤U¡A´N¯à¥¿±`¤F¡A§Ú¤§«e¬O¤@«Ø¥ß·s¶l¥ó«á¡÷§Y©ñ¤JªþÀÉ¡÷¦A¨Ó¤~¬O¼W¥[¦¬¥óªÌ¡÷µM«á¬O¶l¥ó¤º¤å¡A«á¨Ó¡A§Ú¸ÕµÛ§â¶¶§ÇÅܧ󦨡A«Ø¥ß¶l¥ó«á¡÷¼W¥[¦¬¥óªÌ¡÷¶l¥ó¤º¤å¡÷³Ì«á¤~¬OªþÀÉ¡A³o¼Ë´N§¹¥þ¨S¦³°ÝÃD¤F¡C
clio

TOP

        ÀR«ä¦Û¦b : ¯u¥¿ªº·R¤ß¡A¬O·ÓÅU¦n¦Û¤vªº³oÁû¤ß¡C
ªð¦^¦Cªí ¤W¤@¥DÃD