473,463 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Automatic email with multiple lines

AllusiveKitten
Hi all

I am trying to set up an automatic email that requires multiple lines and paragraphs.

Can someone please help me, the coding I have so far only sustains one continuous line.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2.  
  3. Dim Email As String
  4. Dim objOutlook As Outlook.Application
  5. Dim objEmail As Outlook.MailItem
  6.  
  7. Email = "name@company.com"
  8.  
  9. Set objOutlook = CreateObject("Outlook.application")
  10.  
  11. Set objEmail = objOutlook.CreateItem(olMailItem)
  12.  
  13. With objEmail
  14.  
  15.     .To = Email
  16.     .Subject = "Test email document"
  17.     .Body = "This is just a test"
  18.     .Send
  19. End With
  20.  
  21. Set objEmail = Nothing
  22.  
  23. End Sub
Thank you for your help
Oct 18 '07 #1
5 20087
Scott Price
1,384 Expert 1GB
You inadvertently posted your question in the Access Articles section. I have moved it across for you to the main forum.

MODERATOR
Oct 18 '07 #2
Jim Doherty
897 Expert 512MB
Hi all

I am trying to set up an automatic email that requires multiple lines and paragraphs.

Can someone please help me, the coding I have so far only sustains one continuous line.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2.  
  3. Dim Email As String
  4. Dim objOutlook As Outlook.Application
  5. Dim objEmail As Outlook.MailItem
  6.  
  7. Email = "name@company.com"
  8.  
  9. Set objOutlook = CreateObject("Outlook.application")
  10.  
  11. Set objEmail = objOutlook.CreateItem(olMailItem)
  12.  
  13. With objEmail
  14.  
  15. .To = Email
  16. .Subject = "Test email document"
  17. .Body = "This is just a test"
  18. .Send
  19. End With
  20.  
  21. Set objEmail = Nothing
  22.  
  23. End Sub
Thank you for your help

Concatenate your message into a string variable and then assign the variable to the BODY as below demonstrates:

Expand|Select|Wrap|Line Numbers
  1.  Dim mymsg as string 
  2. mymsg = "This is just a test & vbcrlf
  3. mymsg = mymsg & "This is another line" & vbcrlf
  4. mymsg = mymsg & "This is yet another line & vbcrlf & vbcrlf
  5. mymsg = mymsg & "This line has double spaced" 
  6.     .Body = mymsg
  7. .Send
  8.  
Regards

Jim
Oct 18 '07 #3
NeoPa
32,556 Expert Mod 16PB
Notice the vbCRLF that's used in Jim's code. This is a Carriage Return / Line Feed sequence which essentially means a new line.
That is how it is done :)
Oct 18 '07 #4
Thank you both, you are a great help.
Thank you NeoPa for clarifying the meanings.
Oct 18 '07 #5
NeoPa
32,556 Expert Mod 16PB
No problem AK - Glad to help :)
Oct 19 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Rasmus Fogh | last post by:
Someone raised the question of automatic code generation a few weeks back. And yes, we (CCPN) are using automatic Python code generation in a major way. Basically we are making data models in...
3
by: Darleen | last post by:
I am seeking conceptual here on how to get started with a "3D Matrix" in Access. We run a training center which holds multiple classes in multiple cities at multiple times. So I need to create a...
5
by: Shane | last post by:
I wonder if someone has any ideas about the following. I am currently producing some reports for a manufacturing company who work with metal. A finished part can contain multiple sub-parts to...
4
by: pjac | last post by:
I need assistance in creating an Automatic tracking number that appears in a textbox that looks like: 2004-001. The first part of the number is based on the year, the second part is generated from...
1
by: Philip Bondi | last post by:
Hello to all SQL Server junkies who work with non-English characters: For people running scripts from the command line using ANSI files with special characters, it is very important to use isql...
0
by: krouxsa | last post by:
Hi There people... Please help me with this query. I want to send 1 email to multiple email addresses stored in a database. Will it be possible? I'm using SQL Server 2005 and already set up...
5
AllusiveKitten
by: AllusiveKitten | last post by:
Hi all, I really hope I can explain myself properly, I have set up coding to send multiple automatic emails which is working super! Each email that is being sent I receive the security Pop up box...
10
by: karan1981 | last post by:
Hi, I have a user control that has a textbox. This user control is placed in a form at runtime. This form gives a string to the user control and the textbox is to show this in multiple lines.(i...
12
by: DeZZar | last post by:
Hi all, I'll explain my database first. Users input customer details that are required to complete a company document. The document merge etc is all working - the database saves the...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.