mcubeles
01-26-2016, 01:49 PM
Hi
I am new in the forum.
Need some help with this piece of code
-I have a file on the Desktop (text file)
-want to open read the file and copy all the content
-paste the content into body of the email
the piece of code I have is the following, it works opening the file, read the content and put into a variable.
But when trying to put the content into the body of email nothing happen. :(
Sub copyText()
Dim objOutlook As Outlook.Application
Dim itmMail As Outlook.MailItem
Set objOutlook = Outlook.Application
Set itmMail = objOutlook.CreateItem(0)
'I try to change the objOutlook.CreateItem(oldMailItem) nothing
Dim myFile As String, text As String, textline As String, posLat As Integer, posLong As Integer
myFile = "C:\Users\mcubelesgil\Desktop\mytxt.txt"
Open myFile For Input As #1
Do Until EOF(1)
Line Input #1, textline
text = text & vbCrLf & textline
Loop
Close #1
With itmMail
.Body = text
.BodyFormat = olFormatHTML
End With
End Sub
when I put the variable text into msgbox it shows the content of the file, no problem with that.
using Outlook 2013 Any help much appreciate
I am new in the forum.
Need some help with this piece of code
-I have a file on the Desktop (text file)
-want to open read the file and copy all the content
-paste the content into body of the email
the piece of code I have is the following, it works opening the file, read the content and put into a variable.
But when trying to put the content into the body of email nothing happen. :(
Sub copyText()
Dim objOutlook As Outlook.Application
Dim itmMail As Outlook.MailItem
Set objOutlook = Outlook.Application
Set itmMail = objOutlook.CreateItem(0)
'I try to change the objOutlook.CreateItem(oldMailItem) nothing
Dim myFile As String, text As String, textline As String, posLat As Integer, posLong As Integer
myFile = "C:\Users\mcubelesgil\Desktop\mytxt.txt"
Open myFile For Input As #1
Do Until EOF(1)
Line Input #1, textline
text = text & vbCrLf & textline
Loop
Close #1
With itmMail
.Body = text
.BodyFormat = olFormatHTML
End With
End Sub
when I put the variable text into msgbox it shows the content of the file, no problem with that.
using Outlook 2013 Any help much appreciate