메인 컨텐츠로 가기

Excel에 여러 첨부 파일이 첨부 된 이메일을 보내는 방법은 무엇입니까?

이 기사에서는 Excel에 여러 첨부 파일이 첨부 된 Outlook을 통해 전자 메일을 보내는 방법에 대해 설명합니다.

VBA 코드를 사용하여 Excel에 첨부 된 여러 첨부 파일이있는 전자 메일 보내기


VBA 코드를 사용하여 Excel에 첨부 된 여러 첨부 파일이있는 전자 메일 보내기

엑셀에 첨부 된 여러 개의 첨부 파일이있는 이메일을 보내려면 다음과 같이하십시오.

1. 클릭하여 명령 버튼을 삽입하십시오 개발자 > 끼워 넣다 > 명령 단추 (ActiveX 컨트롤). 스크린 샷보기 :

2. Command Button을 삽입 한 후 마우스 오른쪽 버튼을 클릭하고 코드보기 컨텍스트 메뉴에서.

3. 오프닝에서 응용 프로그램 용 Microsoft Visual Basic 창을 클릭하십시오 도구 > 참고자료 아래 스크린 샷과 같이.

4. 에서 참조 – VBAProject 대화 상자를 찾아서 확인하십시오. Microsoft Outlook 개체 라이브러리 옵션을 클릭 한 다음 OK 버튼을 클릭합니다.

5. 그런 다음 코드 창의 원래 코드를 아래 VBA 코드로 바꿉니다.

VBA 코드 : Excel에서 여러 첨부 파일이 첨부 된 전자 메일 보내기

Private Sub CommandButton1_Click()
    Dim xStrFile As String
    Dim xFilePath As String
    Dim xFileDlg As FileDialog
    Dim xFileDlgItem As Variant
    Dim xOutApp As Outlook.Application
    Dim xMailOut As Outlook.MailItem
    Application.ScreenUpdating = False
    Set xOutApp = CreateObject("Outlook.Application")
    Set xMailOut = xOutApp.CreateItem(olMailItem)
    Set xFileDlg = Application.FileDialog(msoFileDialogFilePicker)
    If xFileDlg.Show = -1 Then
        With xMailOut
            .BodyFormat = olFormatRichText
            .To = ""
            .Subject = "test"
            .HTMLBody = "test"
            For Each xFileDlgItem In xFileDlg.SelectedItems
                .Attachments.Add xFileDlgItem
            Next xFileDlgItem
            .Display
        End With
    End If
    Set xMailOut = Nothing
    Set xOutApp = Nothing
    Application.ScreenUpdating = True
End Sub

주의 사항: 이메일 수신자, 제목, 본문을 변경해주세요. .까지 = , .Subject = "테스트".HTMLBody = "테스트" 코드의 줄.

6. 누르세요 다른 + Q 종료하려면 함께 키 응용 프로그램 용 Microsoft Visual Basic 창.

7. 클릭 개발자 > 디자인 모드 디자인 모드를 끕니다. 스크린 샷보기 :

8. 명령 단추를 클릭하여 코드를 실행합니다. 팝업에서 검색 창에서 이메일에 첨부 할 파일을 선택한 다음 OK 단추. 스크린 샷보기 :

9. 그런 다음 지정된 필드와 첨부 파일이 나열된 이메일이 생성됩니다. 클릭하십시오 전송 버튼을 눌러 보내십시오. 스크린 샷보기 :

주의 사항: VBA 코드는 Outlook을 전자 메일 프로그램으로 사용할 때만 작동합니다.


Excel에서 생성 된 메일 링리스트의 필드를 기반으로 Outlook을 통해 쉽게 이메일을 보낼 수 있습니다.

  이메일 보내기 ~의 유용성 Excel 용 Kutools Excel에서 생성 된 메일 링리스트를 기반으로 사용자가 Outlook을 통해 이메일을 보낼 수 있도록 도와줍니다.
지금 다운로드하여 사용해 보세요! (30일 무료 트레일)



관련 기사 :

최고의 사무 생산성 도구

🤖 Kutools AI 보좌관: 다음을 기반으로 데이터 분석을 혁신합니다. 지능형 실행   |  코드 생성  |  사용자 정의 수식 만들기  |  데이터 분석 및 차트 생성  |  Kutools 기능 호출...
인기 기능: 중복 항목 찾기, 강조 표시 또는 식별   |  빈 행 삭제   |  데이터 손실 없이 열이나 셀 결합   |   수식없이 반올림 ...
슈퍼 조회: 다중 기준 VLookup    다중 값 VLookup  |   여러 시트에 걸친 VLookup   |   퍼지 조회 ....
고급 드롭다운 목록: 드롭다운 목록을 빠르게 생성   |  종속 드롭다운 목록   |  다중 선택 드롭 다운 목록 ....
열 관리자: 특정 개수의 열 추가  |  열 이동  |  Toggle 숨겨진 열의 가시성 상태  |  범위 및 열 비교 ...
특색 지어진 특징: 그리드 포커스   |  디자인보기   |   큰 수식 바    통합 문서 및 시트 관리자   |  리소스 라이브러리 (자동 텍스트)   |  날짜 선택기   |  워크 시트 결합   |  셀 암호화/해독    목록으로 이메일 보내기   |  슈퍼 필터   |   특수 필터 (굵게/기울임꼴/취소선 필터링...) ...
상위 15개 도구 세트12 본문 도구 (텍스트 추가, 문자 제거,...)   |   50+ 거래차트 유형 (Gantt 차트,...)   |   40+ 실용 방식 (생일을 기준으로 나이 계산,...)   |   19 삽입 도구 (QR 코드 삽입, 경로에서 그림 삽입,...)   |   12 매출 상승 도구 (숫자를 단어로, 환율,...)   |   7 병합 및 분할 도구 (고급 결합 행, 셀 분할,...)   |   ... 그리고 더

Excel용 Kutools로 Excel 기술을 강화하고 이전과는 전혀 다른 효율성을 경험해 보세요. Excel용 Kutools는 생산성을 높이고 시간을 절약하기 위해 300개 이상의 고급 기능을 제공합니다.  가장 필요한 기능을 얻으려면 여기를 클릭하십시오...

상품 설명


Office Tab은 Office에 탭 인터페이스를 제공하여 작업을 훨씬 쉽게 만듭니다.

  • Word, Excel, PowerPoint에서 탭 편집 및 읽기 사용, Publisher, Access, Visio 및 Project.
  • 새 창이 아닌 동일한 창의 새 탭에서 여러 문서를 열고 만듭니다.
  • 생산성을 50% 높이고 매일 수백 번의 마우스 클릭을 줄입니다!
Comments (14)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
أريد إرسال بريد إلكتروني مع البريد أو hotmail مع CDO ولكن كل ما لدي فقط مع مرفق واحد ولكن أريد أن أرسل مع العديد من المرفقات يرجى إرسال لي عن طريق بريدي الإلكتروني الرمز أو ملف Excel
Rated 5 out of 5
This comment was minimized by the moderator on the site
Is het ook mogelijk om een filter te zetten op de selectie van de bijlagen, zodat er alleen pdf-bestanden aan de mail kunnen worden toegevoegd?
This comment was minimized by the moderator on the site
Hi Alex de Graaf,
The code directly calls the Microsoft's file selection window. This makes it easy for VBA users to select needed files.
This comment was minimized by the moderator on the site
Hi Crystal,
Yes, I do understand that. However, is it possible to restrict users to only select pdf-files?
This comment was minimized by the moderator on the site
Hi Crystal,

Yes, I understand that. However I want the users to only be able to select pdf-files.
Is this possible?
This comment was minimized by the moderator on the site
Hi Alex de Graaf,
The following VBA code lists only the PDF files in the Browse window. Please give it a try.

Private Sub CommandButton1_Click()
'Updated by Extendoffice 20220714
    Dim xStrFile As String
    Dim xFilePath As String
    Dim xFileDlg As FileDialog
    Dim xFileDlgItem As Variant
    Dim xOutApp As Outlook.Application
    Dim xMailOut As Outlook.MailItem
    Application.ScreenUpdating = False
    Set xOutApp = CreateObject("Outlook.Application")
    Set xMailOut = xOutApp.CreateItem(olMailItem)
    Set xFileDlg = Application.FileDialog(msoFileDialogFilePicker)
    xFileDlg.Filters.Add "PDF", "*.pdf", 1
xFileDlg.FilterIndex = 1
    If xFileDlg.Show = -1 Then
        With xMailOut
            .BodyFormat = olFormatRichText
            .To = ""
            .Subject = "test"
            .HTMLBody = "test"
            For Each xFileDlgItem In xFileDlg.SelectedItems
                .Attachments.Add xFileDlgItem
            Next xFileDlgItem
            .Display
        End With
    End If
    Set xMailOut = Nothing
    Set xOutApp = Nothing
    Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Hola,
Me gustaría saber como quedaría la macro si quisiera enviar en un mismo correo a varias personas o más y con varios ficheros o más.
Muchas gracias.
This comment was minimized by the moderator on the site
I have enjoyed working through this solution for adding multiple attachments to an email from within Excel VBA. Thank you. I know that a lot of us benefit and then want some aspect customized for exactly what we are trying to do. I am no different, but for step 8. Can we set the path that the Browse window will open with? I can browse over to another folder at a different location but if I could set the path that would be a time saver.
This comment was minimized by the moderator on the site
Superb...... Works perfectly.
This comment was minimized by the moderator on the site
HI Team ....i am unable to see the attachment in mail so if i follow the your step...can you pls help
This comment was minimized by the moderator on the site
the above code works perfectly thanks!! but my email automatic signature seem to disappear with this code. any idea why?
This comment was minimized by the moderator on the site
What if multiple different user and different attachment to be send with different subject line.
This comment was minimized by the moderator on the site
What if above files are located in sub-folders? How to look for a file in folder and sub-folders?
This comment was minimized by the moderator on the site
I am able to "Quickly send email with multiple attachments attached in Excel with Kutools for Excel" using your steps above, but would like to take it one step further and personalize each email by inserting their names (from a column in the Excel sheet) into the body of the email. While in the body of the email, I try selecting the field and clicking on "Insert Placeholder" but nothing happens. Any idea why or how I can fix this? Thank you!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations