对雷鸟兼容性展望所需的确认 [英] Confirmation required for outlook to thunderbird compatibility
问题描述
我有点卡住了。
需要一个简单的一键程序来获取Excel电子表格中的数据并将其转储到电子邮件正文中然后发送。
我使用下面的代码来创建电子邮件,但是你可以看到它是为Outlook设置的。
这对雷鸟来说也是可行的或者它们是不兼容的吗?
似乎工作但不发送!
(BTW - 抱歉GOTO - 我并不自豪!)
I am a bit stuck.
There is a need for a simple one click program to pick up data on an Excel spreadsheet and dump it into the body of an email then send it.
I am using the code below to create the email but as you can see it is set up for Outlook.
Is this also workable for thunderbird or are they incompatible?
It seems to work but it ain't sending!
(BTW - sorry about the GOTOs - I am not proud!)
Imports Excel = Microsoft.Office.Interop.Excel
Imports Olook = Microsoft.Office.Interop.Outlook
Public Class Form1
Dim xlApp As New Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim xlRange As Excel.Range
Dim olApp As New Olook.Application
Dim olMail As Olook.MailItem
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
xlWorkBook = xlApp.Workbooks.Open("C:\TESTWORKBOOK.xlsx")
xlWorkSheet = xlWorkBook.Sheets("Sheet1")
xlRange = xlWorkSheet.Range("A1:F20")
olMail = olApp.CreateItem(0)
On Error Resume Next
With olMail
.To = "joe.bloggs@someaddress.com"
.CC = ""
.BCC = ""
.Subject = "This is a test"
.HTMLBody = RangetoHTML(xlRange)
.Display()
End With
On Error GoTo 0
xlWorkBook.Close (False)
xlApp.Quit()
releaseObject (xlApp)
releaseObject (xlWorkBook)
End Sub
Function RangetoHTML(rng As Excel.Range)
Dim fso As Object
Dim ts As Object
Dim TempFile As String
Dim TempWB As Excel.Workbook
TempFile = Environ$("temp") & "/" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm"
rng.Copy()
TempWB = xlApp.Workbooks.Add(1)
With TempWB.Sheets(1)
.Cells(1).PasteSpecial(Paste:=8)
.Cells(1).PasteSpecial(-4163, , False, False)
.Cells(1).PasteSpecial(-4122, , False, False)
.Cells(1).Select()
xlApp.CutCopyMode = False
On Error Resume Next
.DrawingObjects.Visible = True
.DrawingObjects.Delete()
On Error GoTo 0
End With
With TempWB.PublishObjects.Add( _
SourceType:=4, _
Filename:=TempFile, _
Sheet:=TempWB.Sheets(1).Name, _
Source:=TempWB.Sheets(1).UsedRange.Address, _
HtmlType:=0)
.Publish (True)
End With
fso = CreateObject("Scripting.FileSystemObject")
ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
RangetoHTML = ts.ReadAll
ts.Close()
RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _
"align=left x:publishsource=")
TempWB.Close(savechanges:=False)
Kill (TempFile)
ts = Nothing
fso = Nothing
TempWB = Nothing
End Function
Private Sub releaseObject(ByVal obj As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject (obj)
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub
End Class
推荐答案
( temp)& ; /&格式(现在, dd-mm-yy h-mm-ss)& 。htm
rng.Copy()
TempWB = xlApp.Workbooks.Add( 1 )
使用 TempWB.Sheets( 1 )
。细胞( 1 )。PasteSpecial(粘贴:= 8) )
。细胞( 1 )。PasteSpecial(-4163 ,, False , False )
.Cells( 1 )。PasteSpecial(-4122 ,, 错误,错误)
。细胞( 1 )。< span class =code-keyword>选择()
xlApp.CutCopyMode = False
开启 错误 恢复 下一步
.DrawingObjects.Visible = True
。 DrawingObjects.Delete()
On 错误 GoTo 0
结束 使用
使用 TempWB.PublishObjects.Add(_
SourceType:= 4,_
文件名:= TempFile,_
Sheet:= TempWB.Sheets( 1 )。姓名,_
来源:= TempWB.Sheets( 1 )。UsedRange.Address,_
HtmlType:= 0)
。发布( True )
结束 使用
fso = CreateObject ( Scripting.FileSystemObject)
ts = fso.GetFile(TempFile).OpenAsTextStream( 1 , - 2)
RangetoHTML = ts.ReadAll
ts.Close()
RangetoHTML = Replace(RangetoHTML, align = center x:publishsource =,_
align = left x:publishsource =)
TempWB.Close(savechanges:= False)
Kill (TempFile)
ts = 没什么
fso = 没什么
TempWB = 无
结束 功能
私人 子版本对象( ByVal obj 作为 对象)
尝试
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = 没有
Catch ex As 例外
obj = Nothing
最后
GC.Collect()
结束 尝试
结束 子
结束 类
("temp") & "/" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm" rng.Copy() TempWB = xlApp.Workbooks.Add(1) With TempWB.Sheets(1) .Cells(1).PasteSpecial(Paste:=8) .Cells(1).PasteSpecial(-4163, , False, False) .Cells(1).PasteSpecial(-4122, , False, False) .Cells(1).Select() xlApp.CutCopyMode = False On Error Resume Next .DrawingObjects.Visible = True .DrawingObjects.Delete() On Error GoTo 0 End With With TempWB.PublishObjects.Add( _ SourceType:=4, _ Filename:=TempFile, _ Sheet:=TempWB.Sheets(1).Name, _ Source:=TempWB.Sheets(1).UsedRange.Address, _ HtmlType:=0) .Publish (True) End With fso = CreateObject("Scripting.FileSystemObject") ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2) RangetoHTML = ts.ReadAll ts.Close() RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _ "align=left x:publishsource=") TempWB.Close(savechanges:=False) Kill (TempFile) ts = Nothing fso = Nothing TempWB = Nothing End Function Private Sub releaseObject(ByVal obj As Object) Try System.Runtime.InteropServices.Marshal.ReleaseComObject (obj) obj = Nothing Catch ex As Exception obj = Nothing Finally GC.Collect() End Try End Sub End Class
对于Thunderbird,您可以使用Shell函数。
这是我发现的一个示例,它向正文添加文本d附上一个文件。
For Thunderbird you could use the Shell function.
Here is an example I found that adds text to the body and attaches a file.
Shell ("C:\Program Files (x86)\Mozilla Thunderbird\Thunderbird.exe -compose to='mymailname@gmail.com',subject='Test message from thunderbird',preselectid='id1',body='Example message from myText.txt',attachment='file:///c:\onwin.png'")
本网站提供Thunderbird的命令行参数: http://kb.mozillazine。 org / Command_line_arguments_(Thunderbird) [ ^ ] < br $> b $ b
祝你好运
This website provides the command line arguments for Thunderbird: http://kb.mozillazine.org/Command_line_arguments_(Thunderbird)[^]
Good luck
这篇关于对雷鸟兼容性展望所需的确认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!