+ Reply to Thread
Results 1 to 5 of 5

Sending Attachment from Excel through Outlook

  1. #1
    Registered User
    Join Date
    05-21-2014
    Posts
    22

    Sending Attachment from Excel through Outlook

    I just tried this yesterday and it worked fine. Now it's not working. Can anyone shed some insight? It goes through the entire code but I don't see it sending an email from Outlook.


    'Code updated for Outlook 2010'
    Dim OutlookApp As Outlook.Application
    Dim MItem As Object
    Dim UserId As String

    Set OutlookApp = New Outlook.Application

    Set MItem = OutlookApp.CreateItem(olMailItem)

    On Error Resume Next
    With MItem
    .To = "strTo"
    .Subject = strSubject
    .BodyFormat = olFormatHTML
    .HTMLBody = strMessageBody
    .Attachments.Add strAttachmentPaths
    .Send
    End With
    On Error GoTo 0

    Set OutlookApp = Nothing

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,621

    Re: Sending Attachment from Excel through Outlook

    What happens if you remove this?
    Please Login or Register  to view this content.
    PS Can you add code tags when posting code?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    05-21-2014
    Posts
    22

    Re: Sending Attachment from Excel through Outlook

    I see that I have a quote around "strTo", could that cause the problem? Since strTo is already itself, I'm not sure what adding quotes to an existing string would mean.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,621

    Re: Sending Attachment from Excel through Outlook

    That will be a problem, Outlook will treat the string 'strTo' as an email or try and look it up in your address book.

    Try removing the "".

  5. #5
    Registered User
    Join Date
    05-21-2014
    Posts
    22

    Re: Sending Attachment from Excel through Outlook

    That worked, thanks! I probably inserted the quote there when I was hard-coding an email address.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Outlook Macro does run properly when sending excel attachment
    By whosphil in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 05-20-2014, 02:30 PM
  2. [SOLVED] VBA Macro to print to Pdf format and place as attachment in Outlook (Excel & Outlook 2007)
    By Webman1012 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-29-2013, 01:25 PM
  3. Attachment is added Twice while sending emial through Excel
    By navneet dusaj in forum Excel General
    Replies: 1
    Last Post: 03-21-2011, 05:18 PM
  4. Sending email attachment(s) from Excel 2007
    By nobleprince in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-28-2010, 12:33 PM
  5. [SOLVED] Workbook minimizes when sending as attachment using Outlook Expres
    By pipepilot in forum Excel General
    Replies: 0
    Last Post: 06-08-2005, 11:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1