Solved Sending Email from Access 2007 thru Outlook 2007

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

nylex40

Thread Starter
Joined
Dec 6, 2016
Messages
3
Tech Support Guy System Info Utility version 1.0.0.4
OS Version: Microsoft Windows 10 Home, 64 bit
Processor: AMD A6-7310 APU with AMD Radeon R4 Graphics, AMD64 Family 22 Model 48 Stepping 1
Processor Count: 4
RAM: 7113 Mb
Graphics Card: AMD Radeon(TM) R4 Graphics, 1024 Mb
Hard Drives: C: 814 GB (753 GB Free); D: 17 GB (2 GB Free); E: 97 GB (73 GB Free);
Motherboard: HP, 81F5
Antivirus: Windows Defender, Disabled

I have a form that gathers the required information from within the database

upload_2016-12-7_0-15-56.png
I then use this code to send the email

Private Sub Command20_Click()
'sending email
Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.BodyFormat = olFormatHTML
.To = Me.Email_Address
.Subject = Me.Mess_Subject
.HTMLBody = Me.messtxt
If Left(Me.Mail_Attachment_Path, 1) <> "<" Then
.Attachments.Add (Me.Mail_Attachment_Path)
End If
'.DeleteAfterSubmit = True 'This would let Outlook send th note without storing it in your sent bin
.Send
End With
'MsgBox MailOutLook.Body
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
Resume Error_out
Error_out:
End Sub

Everything works fine except what the customer sees - sometimes the Text message is a long one and
it gets sent in one long line. I have been googleing for days now but cant find a way to put line feeds in the text
message. All the examples I find only use 4 or 5 words in there text message so it is not a problem

Hope you guys can help
 
Joined
Jan 15, 2004
Messages
770
What I have done in the past is use markers in the messages that I want to email such as

x = "Hello," & " <F> " & "blah blah blah"

Then I use the replace function to replace the <f> with a line feed

mess = Replace(x, "<F>", vbCrLf)

this way when you send the message it will carry the line feeds with it. so in your case you will need to add the <f> into your textbox
 

OBP

Joined
Mar 8, 2005
Messages
19,895
In place of Database's vbCrLf you could also try the very old CHR$(13)
 

nylex40

Thread Starter
Joined
Dec 6, 2016
Messages
3
Tried both - vbCrLf and CHR$(13) - I checked the message in both tries and the alteration was there
When the email was received the message was still in one long line
Could have small messages but wouldn't look very business like
 

OBP

Joined
Mar 8, 2005
Messages
19,895
I notice that you are using BodyFormat = "olFormatHTML"
that may be overriding any formatting that you are adding.
What happens if you remove that line?
 
Joined
Jun 8, 2001
Messages
2,583
To get the parser to work correctly you need to use HTML tags. Something like...
.HTMLBody = "<html><body><pre>" & Me.messtxt & "</pre></body></html>"

HTML doesn't work exactly like you expect here so you may have to play with it
 

nylex40

Thread Starter
Joined
Dec 6, 2016
Messages
3
I notice that you are using BodyFormat = "olFormatHTML"
that may be overriding any formatting that you are adding.
What happens if you remove that line?
I notice that you are using BodyFormat = "olFormatHTML"
that may be overriding any formatting that you are adding.
What happens if you remove that line?
I Have added this line to the code and it works
x = messtxt
messtxt = Replace(x, ".", "<br>")
I have altered the text and put in a "." and when I want a blank line I add ".."
 
Joined
Jun 8, 2001
Messages
2,583
Good job! thanks for letting us know. You can make the thread 'solved' with the button at the top..

Your adding an HTML tag which means your HTMLbody name is working. I would try the line of code I suggested, if it does no harm it will make it a cleaner html body. Might make a difference on some email system.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top