C#在独立应用程序的新Outlook邮件项目中嵌入图像
将图像从独立应用程序嵌入新outlook邮件项目的最佳方式是什么。未为outlook生成外接程序 正在尝试将现有图片嵌入或附加到新电子邮件项目。我已经阅读并查看了很多源代码,但其中大部分都与exchange或Outlook中的AddIn方法有关 用户将看到嵌入到新电子邮件中的图像,只需填写“收件人:”字段。希望在新的电子邮件消息以及应用程序中预先填充主题 下面的代码:(我正在尝试将下面捕获的图片附加到outlook电子邮件中C#在独立应用程序的新Outlook邮件项目中嵌入图像,c#,outlook,embed,native,email-attachments,C#,Outlook,Embed,Native,Email Attachments,将图像从独立应用程序嵌入新outlook邮件项目的最佳方式是什么。未为outlook生成外接程序 正在尝试将现有图片嵌入或附加到新电子邮件项目。我已经阅读并查看了很多源代码,但其中大部分都与exchange或Outlook中的AddIn方法有关 用户将看到嵌入到新电子邮件中的图像,只需填写“收件人:”字段。希望在新的电子邮件消息以及应用程序中预先填充主题 下面的代码:(我正在尝试将下面捕获的图片附加到outlook电子邮件中 using System; using System.Collecti
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net.Mail;
using System.Net.Mime;
namespace While_You_Were_Out
{
public partial class main : Form
{
public main()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
WindowState = FormWindowState.Normal;
Show();
Rectangle l = Screen.PrimaryScreen.WorkingArea;
//Sets Position Manual all other Dialogs are set within parent center area.
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - this.Width, Screen.PrimaryScreen.WorkingArea.Height - this.Height);
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
new AboutDialog().ShowDialog(this);
}
private void trayIcon_MouseDoubleClick(object sender, MouseEventArgs e)
{
WindowState = FormWindowState.Normal;
Show();
Rectangle l = Screen.PrimaryScreen.WorkingArea;
//Sets Position Manual all other Dialogs are set within parent center area.
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - this.Width, Screen.PrimaryScreen.WorkingArea.Height - this.Height);
}
private void trayRightClickMenu2_Opening(object sender, CancelEventArgs e)
{
}
private void toolStripMenuExit_Click(object sender, EventArgs e)
{
//Exit Application
Application.Exit();
}
private void toolStripMenuOpen1_Click(object sender, EventArgs e)
{
WindowState = FormWindowState.Normal;
Show();
Rectangle l = Screen.PrimaryScreen.WorkingArea;
//Sets Position Manual all other Dialogs are set within parent center area.
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - this.Width, Screen.PrimaryScreen.WorkingArea.Height - this.Height);
}
private void button1_Click(object sender, EventArgs e)
{
//Hides to System Tray
this.Hide();
trayIcon.Visible = true;
//Dispose();
}
private void button2_Click(object sender, EventArgs e)
{
}
private void sendNotificationToolStripMenuItem_Click(object sender, EventArgs e)
{
/* Bitmap bmp = new Bitmap(panel1.Width, panel1.Height);
panel1.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
bmp.Save(@"C:\Razor\wywo_notification.jpg");
bmp.Dispose();*/
SaveAsBitmap(panel1, @"C:\Users\Razor\wywo_notification.jpg");
}
private void clearFormToolStripMenuItem_Click(object sender, EventArgs e)
{
txtBox6.Text = string.Empty;
txtBox8.Text = string.Empty;
txtBox9.Text = string.Empty;
}
public void SaveAsBitmap(Control control, string fileName)
{
//get the instance of the graphics from the control
Graphics g = control.CreateGraphics();
//new bitmap object to save the image
Bitmap bmp = new Bitmap(panel1.Width, panel1.Height);
//Drawing control to the bitmap
panel1.DrawToBitmap(bmp, new Rectangle(0, 0, control.Width, control.Height));
bmp.Save(fileName);
bmp.Dispose();
}
private void sendToOutlook_Click(object sender, EventArgs e)
{
}
}
}
我能够使用VBS脚本执行该功能:
Set olApp = CreateObject("Outlook.Application")
Set olMsg = olApp.CreateItem(0)
With olMsg
.To = "test@test.com"
'.CC = "cc@test.com"
'.BCC = "bcc@test.com"
.Subject = "Subject"
.HTMLBody = "<html><p>This is a picture.</p>" & _
"<img src='cid:wywo_notification.jpg'>"
'.Body = "<IMG align=baseline border=0 hspace=0 src=cid:myident>"
'.Attachments.Add "C:\users\doej\wywo_notification.jpg"
'.Attachments.Add "C:\users\doej\wywo_notification.jpg"
.Display
End With
Set olApp=CreateObject(“Outlook.Application”)
Set olMsg=olApp.CreateItem(0)
与奥尔姆格
.To=”test@test.com"
“.CC=”cc@test.com"
“.BCC=”bcc@test.com"
.Subject=“Subject”
.HTMLBody=“这是一张图片。”&_
""
'.Body=“”
'.Attachments.Add“C:\users\doej\wywo_notification.jpg”
'.Attachments.Add“C:\users\doej\wywo_notification.jpg”
.展示
以
您现有的代码是什么?创建一个附件,并使用attachment.PropertyAccessor设置PR_ATTACH_CONTENT_ID属性(DASL name“”)
然后,您的HTML正文需要通过cid引用该图像附件:
img src=“cid:xyz”
其中xyz是PR_ATTACH_CONTENT_ID属性的值
使用(单击IMessage按钮)查看现有邮件。我可以依靠从应用程序中调用的VBS脚本来解决我的问题,这很简单,解决了我的问题。我没有,我尝试添加了Interlop部分,但我不知道它是如何工作的。我正在使用Office 2013(32位)使用windows 8 x64bit。您可能希望使用该特定问题启动一个新线程。