Armitage2k
Registered User.
- Local time
- Today, 13:04
- Joined
- Oct 10, 2009
- Messages
- 34
Hi!
Here my code for generating an email out of my database:
What I would like to do is to get the message body from a textfile instead of entering it as a string directly into the code.
However, this method should be reliable in terms of format, e.g. I need to have linebreaks in the email exactly like in textfile, etc.
I would appreciate every help!
A2k
Here my code for generating an email out of my database:
Code:
Private Sub SendEmail2_Click()
Dim EmailApp, NameSpace, EmailSend As Object
Dim strTitle, strFn, strLN, strBody As String
Set EmailApp = CreateObject("Outlook.Application")
If EmailApp Is Nothing Then Set EmailApp = CreateObject("Outlook.Application")
Set NameSpace = EmailApp.GetNamespace("MAPI")
Set EmailSend = EmailApp.CreateItem(0)
strTitle = Me![Title]
strFn = Me![First Name]
strLN = Me![Last Name]
strBody = "Dear " & strTitle & " " & strFn & " " & strLN & "," & Chr(13) & Chr(13)
strBody = strBody & "Warm greetings!" & Chr(13) & Chr(13)
strBody = strBody & "My name is Lala." & Chr(13)
strBody = strBody & "I live in Lulu."
strBody = strBody & "Shipping method: " & [Position] & Chr(13)
strBody = strBody & "Date shipped: " & [Birthdate] & Chr(13)
strBody = strBody & "Tracking / Confirmation number: " & [ProfileID] & Chr(13)
strBody = strBody & "Sincerely," & Chr(13) & Chr(13)
strBody = strBody & "Acme Corporation"
If IsNull([Email]) Or ([Email]) = "" Then
MsgBox "There is no E-mail address entered for this person!"
Exit Sub
Else
With EmailSend
.Subject = "Warm Greetings!"
.To = Me.Email
'.CC = ""
'.From = "some@one.com"
.Body = strBody
'.Attachments.Add "C:\attachment.txt"
'.Attach = strFilePath & "\" & strFileName
'.AttachFile strFilePath & "\" & strFileName, strFileName
.Display
End With
End If
Set EmailApp = Nothing
Set NameSpace = Nothing
Set EmailSend = Nothing
End Sub
What I would like to do is to get the message body from a textfile instead of entering it as a string directly into the code.
However, this method should be reliable in terms of format, e.g. I need to have linebreaks in the email exactly like in textfile, etc.
I would appreciate every help!
A2k
Last edited: