S
Stephen Plotnick
WordFileName = "C:\temp\Steve.HTM"
Dim WordContent As String
Dim AppWord As New Microsoft.Office.Interop.Word.ApplicationClass
With AppWord
.Visible = False
.ScreenUpdating = False
.DisplayAlerts = WdAlertLevel.wdAlertsNone
End With
Dim WordDoc As Microsoft.Office.Interop.Word.Document
WordDoc = AppWord.Documents.Open(CType(WordFileName, Object))
WordDoc.Content.Select()
WordDoc.Content.Copy()
Dim objClipboard As IDataObject = Clipboard.GetDataObject()
If objClipboard.GetDataPresent(DataFormats.Html) Then
WordContent = objClipboard.GetData(DataFormats.Html)
Else
WordContent = "XXX"
End If
WordDoc.Close()
WordDoc = Nothing
AppWord.Quit()
Filename = "C:\temp\IL Broker List.xls"
If Not File.Exists(Filename) Then
Console.WriteLine("E-mail name and address file does not exist")
automail("(e-mail address removed);", "Problem with STEVE.xls" ,
"Please ensure spreadsheet of E-mail address is in the C:\TEMP directory",
WordFileName)
Else
Console.WriteLine("Sending documents")
obook = GetObject("C:\TEMP\STEVE.xls")
Dim irow As Integer
Dim SendPersonName As String
For irow = 2 To 25000
If obook.Worksheets(1).Cells(irow, 1).value <> "" Then
'MsgBox(obook.Worksheets(1).Cells(irow, icol).Value)
SendPersonName = obook.Worksheets(1).cells(irow,
2).value & " " & obook.Worksheets(1).cells(irow, 3).value
Console.WriteLine(SendPersonName)
automail(obook.Worksheets(1).Cells(irow, 1).value,
"Looking To Buy Investment Propert ", WordContent, WordFileName)
Else
irow = 25000
End If
Next
End If
Close_rtn()
End Sub
Public Sub automail(ByVal mail_to As String, ByVal subject As String,
ByVal msg As String, ByVal filename As String)
Dim myOutlook As New Outlook.Application()
Dim myMailItem, attach As Object
myMailItem = myOutlook.CreateItem(Outlook.OlItemType.olMailItem)
myMailItem.HTMLbody = msg
If File.Exists(filename) Then
attach = myMailItem.Attachments
'DO NOT Send the attachement
'attach.Add(filename)
End If
If Trim(mail_to) <> "" Then
myMailItem.To = Trim(mail_to)
End If
myMailItem.SendUsingAccount =
myOutlook.Application.Session.Accounts("WellInvestments")
'myMailItem.SendUsingAccount = "WellInvestments"
subject = subject
myMailItem.Subject = subject
myMailItem.Send()
myMailItem = Nothing
myOutlook = Nothing
End Sub
Problem 1:
In the SendUsingAccount (not commented) I get the error below.
In the SendUsingAccount (commented out) the program processes but it sends
out from ny default E-mail.
Problem 2:
I have a Word Docement that I want to get the information into the body of
the E-mail. There is simple formatting, like bold and undeline. I've tried
"DOC", "DOCX", "RTF", "HTM". I cannot get the text to look correct. It is
either non formatted text or ends up having all kinds of HTML code.
Thanks in advance for assistance,
Steve
System.Reflection.TargetParameterCountException was unhandled
Message="Number of parameters specified does not match the expected
number."
Source="Microsoft.VisualBasic"
StackTrace:
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object
o, Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack)
at
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at DaveWellsEMAIL.Module1.automail(String mail_to, String subject,
String msg, String filename) in C:\Users\Stephen Plotnick\Documents\Visual
Studio 2005\Projects\DaveWellsEMAIL\DaveWellsEMAIL\Module1.vb:line 95
at DaveWellsEMAIL.Module1.Main() in C:\Users\Stephen
Plotnick\Documents\Visual Studio
2005\Projects\DaveWellsEMAIL\DaveWellsEMAIL\Module1.vb:line 69
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Dim WordContent As String
Dim AppWord As New Microsoft.Office.Interop.Word.ApplicationClass
With AppWord
.Visible = False
.ScreenUpdating = False
.DisplayAlerts = WdAlertLevel.wdAlertsNone
End With
Dim WordDoc As Microsoft.Office.Interop.Word.Document
WordDoc = AppWord.Documents.Open(CType(WordFileName, Object))
WordDoc.Content.Select()
WordDoc.Content.Copy()
Dim objClipboard As IDataObject = Clipboard.GetDataObject()
If objClipboard.GetDataPresent(DataFormats.Html) Then
WordContent = objClipboard.GetData(DataFormats.Html)
Else
WordContent = "XXX"
End If
WordDoc.Close()
WordDoc = Nothing
AppWord.Quit()
Filename = "C:\temp\IL Broker List.xls"
If Not File.Exists(Filename) Then
Console.WriteLine("E-mail name and address file does not exist")
automail("(e-mail address removed);", "Problem with STEVE.xls" ,
"Please ensure spreadsheet of E-mail address is in the C:\TEMP directory",
WordFileName)
Else
Console.WriteLine("Sending documents")
obook = GetObject("C:\TEMP\STEVE.xls")
Dim irow As Integer
Dim SendPersonName As String
For irow = 2 To 25000
If obook.Worksheets(1).Cells(irow, 1).value <> "" Then
'MsgBox(obook.Worksheets(1).Cells(irow, icol).Value)
SendPersonName = obook.Worksheets(1).cells(irow,
2).value & " " & obook.Worksheets(1).cells(irow, 3).value
Console.WriteLine(SendPersonName)
automail(obook.Worksheets(1).Cells(irow, 1).value,
"Looking To Buy Investment Propert ", WordContent, WordFileName)
Else
irow = 25000
End If
Next
End If
Close_rtn()
End Sub
Public Sub automail(ByVal mail_to As String, ByVal subject As String,
ByVal msg As String, ByVal filename As String)
Dim myOutlook As New Outlook.Application()
Dim myMailItem, attach As Object
myMailItem = myOutlook.CreateItem(Outlook.OlItemType.olMailItem)
myMailItem.HTMLbody = msg
If File.Exists(filename) Then
attach = myMailItem.Attachments
'DO NOT Send the attachement
'attach.Add(filename)
End If
If Trim(mail_to) <> "" Then
myMailItem.To = Trim(mail_to)
End If
myMailItem.SendUsingAccount =
myOutlook.Application.Session.Accounts("WellInvestments")
'myMailItem.SendUsingAccount = "WellInvestments"
subject = subject
myMailItem.Subject = subject
myMailItem.Send()
myMailItem = Nothing
myOutlook = Nothing
End Sub
Problem 1:
In the SendUsingAccount (not commented) I get the error below.
In the SendUsingAccount (commented out) the program processes but it sends
out from ny default E-mail.
Problem 2:
I have a Word Docement that I want to get the information into the body of
the E-mail. There is simple formatting, like bold and undeline. I've tried
"DOC", "DOCX", "RTF", "HTM". I cannot get the text to look correct. It is
either non formatted text or ends up having all kinds of HTML code.
Thanks in advance for assistance,
Steve
System.Reflection.TargetParameterCountException was unhandled
Message="Number of parameters specified does not match the expected
number."
Source="Microsoft.VisualBasic"
StackTrace:
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object
o, Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack)
at
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at DaveWellsEMAIL.Module1.automail(String mail_to, String subject,
String msg, String filename) in C:\Users\Stephen Plotnick\Documents\Visual
Studio 2005\Projects\DaveWellsEMAIL\DaveWellsEMAIL\Module1.vb:line 95
at DaveWellsEMAIL.Module1.Main() in C:\Users\Stephen
Plotnick\Documents\Visual Studio
2005\Projects\DaveWellsEMAIL\DaveWellsEMAIL\Module1.vb:line 69
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()