如何发送已创建好的一批邮件

wdy801229 2009-02-09 11:05:33
已用outlook手动创建了一批邮件(50封左右),如何不用每封邮件都点发送,而一次将邮件全部发出。
望指点
...全文
110 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
abel_cn 2009-02-17
  • 打赏
  • 举报
回复
呵呵。。网速太慢了。多发了一遍,不好意思~~~
abel_cn 2009-02-17
  • 打赏
  • 举报
回复
新建一个outlook add-in程序。

1、添加命名空间
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;


2、添加方法
//添加工具栏
private void AddToolBar()
{

atExplorer = AppOutlook.ActiveExplorer();

Office.CommandBars bars = atExplorer.CommandBars;

if (bars == null)
return;

foreach (Office.CommandBar bar in bars)
{
if (bar.Name.ToLower().Trim() == "mzbar")
{
bar.Delete();
}
}

Office.CommandBar mzBar = atExplorer.CommandBars.Add("mzBar", 1, null, null);
if (mzBar != null)
{
btnSend = (Office.CommandBarButton)mzBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true);
if (btnSend != null)
{
btnSend.Caption = "发送(&S)";
btnSend.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
btnSend.TooltipText = "发送";
btnSend.FaceId = 3277;
btnSend.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnSend_Click);
}
mzBar.Visible = true;
}
}


3、将该方法添加到以下事件中
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
AppOutlook = Application;
AddToolBar();
}


4、为按钮添加事件实现
        void btnSend_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
{
Outlook.Selection scItems;

//取Active窗口的选择项
scItems = atExplorer.Selection;

//取得Outlook的文件夹命名空间
Outlook.NameSpace olNs = AppOutlook.GetNamespace("MAPI");

//如果当前不是草稿箱退出
if (atExplorer.CurrentFolder.FolderPath != olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts).FolderPath)
return;

//遍历所有选中的项发送,发送前判断类型是不是邮件。
foreach (Outlook.MailItem miItem in scItems)
{
if (miItem != null)
{
if (miItem.To.Trim().Length > 0)
{
miItem.Send();
}
}
}
}


我是在vs2008+outlook2007中测试通过~~~

呵呵。。。LZ参考下吧~~~
abel_cn 2009-02-17
  • 打赏
  • 举报
回复
新建一个outlook add-in程序。

1、添加命名空间
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;


2、添加方法
//添加工具栏
private void AddToolBar()
{

atExplorer = AppOutlook.ActiveExplorer();

Office.CommandBars bars = atExplorer.CommandBars;

if (bars == null)
return;

foreach (Office.CommandBar bar in bars)
{
if (bar.Name.ToLower().Trim() == "mzbar")
{
bar.Delete();
}
}

Office.CommandBar mzBar = atExplorer.CommandBars.Add("mzBar", 1, null, null);
if (mzBar != null)
{
btnSend = (Office.CommandBarButton)mzBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true);
if (btnSend != null)
{
btnSend.Caption = "发送(&S)";
btnSend.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
btnSend.TooltipText = "发送";
btnSend.FaceId = 3277;
btnSend.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnSend_Click);
}
mzBar.Visible = true;
}
}


3、将该方法添加到以下事件中
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
AppOutlook = Application;
AddToolBar();
}


4、为按钮添加事件实现
        void btnSend_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
{
Outlook.Selection scItems;

//取Active窗口的选择项
scItems = atExplorer.Selection;

//取得Outlook的文件夹命名空间
Outlook.NameSpace olNs = AppOutlook.GetNamespace("MAPI");

//如果当前不是草稿箱退出
if (atExplorer.CurrentFolder.FolderPath != olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts).FolderPath)
return;

//遍历所有选中的项发送,发送前判断类型是不是邮件。
foreach (Outlook.MailItem miItem in scItems)
{
if (miItem != null)
{
if (miItem.To.Trim().Length > 0)
{
miItem.Send();
}
}
}
}


我是在vs2008+outlook2007中测试通过~~~

呵呵。。。LZ参考下吧~~~
arong1234 2009-02-13
  • 打赏
  • 举报
回复
把这些邮件放到同一个文件夹中,创建一个宏,然后选中所有的这些邮件,在宏里写下:

Sub SendMails

Dim oEx
set oEx=Application.ActiveExplorer
set sels = oEx.Selection
foreach sel in sels
sel.send
next
End Sub
sendto66 2009-02-12
  • 打赏
  • 举报
回复
友情up
netsocket 2009-02-12
  • 打赏
  • 举报
回复
友情up
nokia4321 2009-02-10
  • 打赏
  • 举报
回复
看看,MAIL这东西还是手工发的好

5,139

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 Office开发/ VBA
社区管理员
  • Office开发/ VBA社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧