lutonian
Member
- Joined
- Apr 5, 2013
- Messages
- 16
- Programming Experience
- Beginner
Hello All,
I need help I want to create a method to send templates of a word document or html as a part of the body of an email.
At the moment with the code below I can replace the content and copy in a local place.
But when I send it the body appaears in blank.
Any ideas?
Thank you.
I need help I want to create a method to send templates of a word document or html as a part of the body of an email.
At the moment with the code below I can replace the content and copy in a local place.
But when I send it the body appaears in blank.
VB.NET:
Imports Outlook = Microsoft.Office.Interop.Outlook
Imports Microsoft.Office.Core
Imports System.Runtime.InteropServices
Imports Microsoft.Office.Interop.Outlook
Imports System.Data.OleDb
Imports System.IO
Public sub button (??..
Dim myStreamReaderL1 As System.IO.StreamReader
Dim myStream As System.IO.StreamWriter
Dim myStr As String
Dim pathin As String = "c:\users\" + Environment.UserName + "\Desktop\CalendarAssigneeTool\CalendarAssigneeTool\Resources\CC1ENGLISH.docx"
Dim pathout As String = "c:\users\" + Environment.UserName + "\Desktop\CC1_ENGLISHout.docx"
System.IO.File.Copy(pathin, pathout, True)
'####################################################
myStreamReaderL1 = System.IO.File.OpenText(pathout)
myStr = myStreamReaderL1.ReadToEnd()
myStreamReaderL1.Close()
'Modifica el archivo en una nueva copia, manteniendo el archivo original
myStr = myStr.Replace("[NAME]", UserTMPTxt.Text)
myStr = myStr.Replace("[NUMINC1]", IncTMPTxt.Text)
myStr = myStr.Replace("[NUMINC2]", IncTMPTxt.Text)
myStr = myStr.Replace("[ISSUE]", IssueTMPTxt.Text)
'Como modificar contenido word doc.
'Save myStr
myStream = System.IO.File.CreateText(pathout)
myStream.WriteLine(myStr)
myStream.Close()
Conex.Close()
'####################################################
If EmailTMPTxt.Text = "" Or IncTMPTxt.Text = "" Then
MsgBox("Email addresss and Incident number is empty", MsgBoxStyle.Exclamation)
ElseIf Not EmailTMPTxt.Text = "" Or IncTMPTxt.Text = "" Then
item = olApp.CreateItem(Outlook.OlItemType.olMailItem)
item.Application.CreateItemFromTemplate(pathout)
item.SentOnBehalfOfName = "[EMAIL="tracking.sd@airbus.com"]tracking.sd@airbus.com[/EMAIL]"
item.To = EmailTMPTxt.Text
item.Subject = "CC1 - Incident number " + IncTMPTxt.Text
item.Send()
MsgBox("Mail has sent")
EmailTMPTxt.Text = ""
IncTMPTxt.Text = ""
UserTMPTxt.Text = ""
IssueTMPTxt.Text = ""
CommentTMPTxt.Text = ""
End Sub
Thank you.