C#Outlook多个附件组合为1个单独 [英] C# Outlook multiple attachments combine to 1 single

查看:107
本文介绍了C#Outlook多个附件组合为1个单独的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我们有一个邮箱,用户可以在其中发送带附件的电子邮件。附件可以是任何数字。我们有一个要求,让我们说id用户在jpeg类型上发送带有5个附件的电子邮件,然后我们需要将所有5个附件合并为1并保存。
i如何在C#中做到这一点?


任何指针都将受到赞赏!


谢谢!

解决方案

Hello Viral,


您可以处理
ItemSend
触发的Application类事件  每当用户通过 发送Microsoft Outlook项目时;  检查员  (在
之前,检查员关闭,但在用户点击 
发送  按钮)
或者当 
发送  方法
用于Outlook项目。因此,您可以查看作为参数传递的项目的附件集合,并在需要时取消任何进一步处理(请参阅取消参数)。例如,VBA宏:

 Public WithEvents myOlApp As Outlook.Application 


Public Sub Initialize_handler()
设置myOlApp = Outlook.Application
End Sub

Private Sub myOlApp_ItemSend(ByVal Item As Object,Cancel As Boolean)
Dim prompt As String
prompt ="你确定要发送& ;; Item.Subject& ;;"?"
如果MsgBox(提示,vbYesNo + vbQuestion," Sample")= vbNo那么
取消=真
结束如果
结束子

我们
需要将所有5个附件合并为1并保存。



Attachments集合没有提供任何动态处理附件的方法。您需要先将附件保存在磁盘上(参见

SaveAsFile
方法),对保存的文件执行任何操作,然后重新添加它。 



Hello,

We have a mailbox where users send emails with attachments. The attachments can be any number. We have a requirement where lets say id a users send email with 5 attachments on type jpeg then we need to combine all 5 attachments into 1 and save it. How do i do it in C#?

Any pointers will be appreciated!

Thanks!

解决方案

Hello Viral,

You can handle the ItemSend event of the Application class which is fired whenever an Microsoft Outlook item is sent, either by the user through an  Inspector (before the inspector is closed, but after the user clicks the Send button) or when the Send method for an Outlook item. So, you can check out the Attachments collection of the item passed as an argument and cancel any further processing if required (see the Cancel parameter). For example, a VBA macro:

Public WithEvents myOlApp As Outlook.Application 


Public Sub Initialize_handler() 
 Set myOlApp = Outlook.Application 
End Sub 

Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean) 
 Dim prompt As String 
 prompt = "Are you sure you want to send " &; Item.Subject &; "?" 
 If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then 
  Cancel = True 
 End If 
End Sub

we need to combine all 5 attachments into 1 and save it.

The Attachments collection doesn't provide any methods for dealing with attachments on the fly. You need to save the attachment on the disk first (see the SaveAsFile method), do whatever you need with the file saved and then you can re-add it anew.  


这篇关于C#Outlook多个附件组合为1个单独的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆