+ Reply to Thread
Results 1 to 10 of 10

Auto send mail with attachment

  1. #1
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Auto send mail with attachment

    Dear Friends,
    I want to send the mail through m. s. outlook 2007 with attachment automatically. I'm getting error in code. Please correct it and add code to attach a attachment to the mail automatically.

    Thanking you in anticipation.

    Mukesh
    Attached Files Attached Files
    Last edited by mukeshbaviskar; 08-11-2013 at 05:21 AM. Reason: Attach a attachment.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,368

    Re: Auto send mail with attachment

    Maybe:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Auto send mail with attachment

    Hello TMShucks,
    Thank you. I tried it but getting error as follows:

    Compile error: user-define type not defined

    Please remove the error. See the attached file.

    Mukesh
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Auto send mail with attachment

    I have solved the problem but only one error message is to be tackle. The code automatically attaches the attachment but after that I get the following warning message:

    A program is trying to send an e-mail message on your behalf.
    If it is unexpected, click deny and verify your antivirus software up-to-date

    For more information about email safety and how you might be able to avoid getting warning, click help

    After clicking allow the message with attachment is sent.
    Actually my antivirous program is update. I'm using quick heal antivirus program.
    Please solve the problem.

    I also want to add message in message body as follows:

    Dear ..., (here I want to type the name of person whose birthday is on that day)
    Wish you many many happy returns of the day. Happy birthday.

    Have a nice day.

    Regards

    Mukesh


    Thanking you in anticipation.

    Mukesh
    Attached Files Attached Files

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,368

    Re: Auto send mail with attachment

    There were two problems with your original code:

    1) it needed a reference to Microsoft Outlook 12.0 Object Library: corrected by adding the reference in Tools | references
    2) you compare the month (birthday vs now) which fails if the cell contains "-": corrected by testing for the hyphen/minus sign

    You wanted to add an attachment. You do that by including:
    Please Login or Register  to view this content.
    with the full path/name of the file you want/need to attach.

    You've now added a workbook open in the middle of the code; I don't know why you're doing that.

    Finally, you want to add a message in the body of the email. You already had that but you've taken out the code line where you build the message and the line where it is included in the email. Why?

    If I run the original code with the reference to the object library and my amendments, it runs through with no security questions. If I change .Display to .Send it automatically sends the emails.

    So, I guess it's down to your Operating System, Security Options, or the interaction with your Anti-virus system.

    I'm using Windows 7 and Excel+Outlook 2007

    Regards, TMS

  6. #6
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Auto send mail with attachment

    Dear TMShucks,
    Good morning! Thank you for guidance. I corrected my first mistake but unable to correct second mistake. I didn't understand the dash sign problem. I want the message body and attachment.

    Due to my poor knowledge of vba I'm unable to correct the mistakes easily.

    So I humbly request you to do the necessary changes in my code and send me an amended version of it today to avoide any mistake by me again.

    Do send me an amended version. I will go through it and learn my mistake and understand the code well. Thanking you in anticipation.

    Mukesh
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    12-27-2012
    Location
    cebu, Philippines
    MS-Off Ver
    Excel 2016
    Posts
    210

    Re: Auto send mail with attachment

    tmshucks means the problem is not in the code anymore, but in your own computer settings..
    don't worry, there's a lot of people that are far more confused than you
    but if you liked what i suggested. Click for me the "Add Reputation" - that way, we'd be both happy.

  8. #8
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Auto send mail with attachment

    No! TMShucks pointed out problems in my code and ask me to clear it to solve the problem. I clear one problem but unable to clear other problem so I humbly requested him to do the necessary changes in my file and send me the amended version to me positively.

    I want to solve my problem so again I request TMShucks to send me a revised version with corrections.

    Thanking you in anticipation.

    Mukesh

  9. #9
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Auto send mail with attachment

    Dear TMShucks,
    Good morning! I'm eagerly waiting for your response please. I included the workbook event to enter the name of a person whose birthday is on that particular day in the attachment. It attaches the attachment but only problem is that the message is not in message body. I want to tackle it with the help of you. I'm attaching a birthday wishing attachment here so you will understand it.

    Please go through it and do help me to solve the problem.

    Thanking you in anticipation.

    Mukesh Baviskar
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: Auto send mail with attachment

    Dear friends,
    In my file I'm not getting any error but the mail is not send with attachment. I have modified the code.

    Please go through it and correct my code to send the mail with attachment.

    Thanking you in anticipation.

    Mukesh
    Attached Files Attached Files

+ 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. Excel send e-mail with two attachment
    By rbbahia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-10-2013, 03:27 PM
  2. Code to send an e-mail. Don't send if attachment not found
    By thedon_1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-24-2012, 05:41 PM
  3. [SOLVED] Send E-Mail with Attachment
    By Vladamir in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-11-2012, 02:52 PM
  4. Excel Send to Mail Recipient (as Attachment)
    By Dave in forum Excel General
    Replies: 2
    Last Post: 02-23-2006, 05:15 PM
  5. [SOLVED] send to mail recipient as attachment - no worky...
    By Scott McDonald in forum Excel General
    Replies: 0
    Last Post: 04-22-2005, 09:08 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