Sending Emails with Attachments VBA

前端 未结 4 1569
没有蜡笔的小新
没有蜡笔的小新 2021-01-19 19:09

I am trying to add an attachment functionality to my emails. My email code is working however the attachments are being sent as ATT00001.bin files.

The variable Form

4条回答
  •  一个人的身影
    2021-01-19 19:40

    The problem is with your SMTP server. Try putting the attachment after the body to avoid this problem. If that doesn't work, try sending the message as plain text instead of HTML using:

    .TextBody = bodyText
    

    EXAMPLE:

    attachmentlnkvar = "C:/Users/desktopname/Desktop/" & Forms![frmMain]!TabCtl54.Pages("page56").Controls("subtblcontent").Form![attachmentlnk] & ".pdf"
    
    With cdomsg
        .To = emailstr
        .FROM = fromemailstr
        .Subject = Forms!frmMain.txtSubject
        .HTMLBody = strHTML
        .AddAttachment attachmentlnkvar
        .Send
    End With
    
    Set cdomsg = Nothing
    

    EXPLANATION: https://kb.mit.edu/confluence/pages/viewpage.action?pageId=4981187

提交回复
热议问题