+ Reply to Thread
Results 1 to 7 of 7

Code to send mail copying from Excel to a new outlook mail.

  1. #1
    Registered User
    Join Date
    10-10-2015
    Location
    Stockholm
    MS-Off Ver
    Windows 7
    Posts
    16

    Code to send mail copying from Excel to a new outlook mail.

    Hi guys.

    I wanted to create a code where i press a button (mail) and it copies all data within column B2 and I20.
    Then it paste the data into a new Outlook mail where i can send it.

    I almost made it. This is the code i did:
    Please Login or Register  to view this content.

    It works fine but it inserts empty cells from excel into the outlook mail. I want the Set rngBody = .Range("B1:I20") to skip blanks when it copies. How do i do that?
    Attached Files Attached Files
    Last edited by paz1987; 10-19-2015 at 02:54 AM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Code to send mail copying from Excel to a new outlook mail.

    Read post 6

    http://www.excelforum.com/excel-prog...ml#post4212137
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    10-10-2015
    Location
    Stockholm
    MS-Off Ver
    Windows 7
    Posts
    16

    Re: Code to send mail copying from Excel to a new outlook mail.

    Thank you for your help but I probably dont get it. From what i can see your code doesnt take out the spaces in outlook either.

    I used your code to send a mail to myself but i deleted some of the "test" rows. And it still got sent like this in the email.
    spaces.png

    I dont want any spaces. I want it to skip those cells that are empty..

    Also if I only have test written out on A1 to I5, it still copies the empty cells from I20 into the mail. So you get alot of spaces in the mail.

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Code to send mail copying from Excel to a new outlook mail.

    All you need to do is sort your data

    Then Resize your data to get rid of your spaces.

    I will write you the code to do that

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mehmetcik; 10-10-2015 at 12:35 PM.

  5. #5
    Registered User
    Join Date
    10-10-2015
    Location
    Stockholm
    MS-Off Ver
    Windows 7
    Posts
    16

    Re: Code to send mail copying from Excel to a new outlook mail.

    Im sry. But that code doesnt work either. It feels like that code is kinda overboard of what i need?

    I will upload the excel file that im working on. I probably dont understand, as i said im new to code, and maybe im not good at explaining whats wrong but my codes range is A1:G10. I have inserted some text in the first 3 rows. The rest is blank. When i press the "Mail" button in Sheet2 (named Uttag) all the empty cells copies over to the mail too. I want the code to only copy cells which has something written in it.

    This is how i get it now. The red marker is what i would like to avoid..
    spaces2.png

    Sry if im annoying. And i am very grateful for all the help.

  6. #6
    Registered User
    Join Date
    10-10-2015
    Location
    Stockholm
    MS-Off Ver
    Windows 7
    Posts
    16

    Re: Code to send mail copying from Excel to a new outlook mail.

    Here is the workbook..Lager test3.xlsm

  7. #7
    Registered User
    Join Date
    10-10-2015
    Location
    Stockholm
    MS-Off Ver
    Windows 7
    Posts
    16

    Re: Code to send mail copying from Excel to a new outlook mail.

    I solved it kinda myself. in my code i added the Search and mark->Go to special->Constant and then i copied. Then when it paste in to the outlook mail only Constants will be pasted.

    This is the code i used.
    Please Login or Register  to view this content.
    spaces3.png

    The only issue is that if any cells between A1:F111 is empty then i get "Command cant copy multiple rows". Any way around that?

+ 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. VBA code to send mail automatically from outlook
    By aravindkm in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-28-2014, 08:07 AM
  2. Help on Excel Macro/VBA Function to assign code to send outlook mail to multiple Receipt's
    By breadwinner in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 04-25-2013, 06:28 AM
  3. Replies: 0
    Last Post: 04-24-2013, 12:49 PM
  4. Send e-mail with image on body (.html) on e-mail manager <> outlook
    By mariotnc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-05-2012, 09:28 PM
  5. How to e-mail selected row and use e-mail address in a cell to send e-mail from excel
    By syedalamgir in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-27-2010, 02:15 AM
  6. Send Mail - Code to test whether Lotus Notes / Outlook is used
    By Andibevan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-12-2005, 11:05 AM
  7. How can I use Outlook express to send mail rather than Outlook by VBA code
    By new.microsoft.com in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-03-2005, 11:05 AM
  8. [SOLVED] How can I use Outlook express to send mail rather than Outlook by VBA code
    By new.microsoft.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-01-2005, 08:05 AM

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