Я пытаюсь решить проблему, когда надстройка Express дважды щелкает, чтобы отправить электронное письмо в Outlook, когда этот плагин установлен.
Это для системы Windows 10, разрабатываемой с помощью сообщества Visual Studio 2017 и Add-В Экспресс.Я взял на себя очень старый проект с целью добавить плагин в Outlook для нашей системы DMS.
Структура проекта
Плагин разработан в VB, нет ответаили обратная связь в консоли при попытке отладки в Outlook.
/ Common / SettingSer.vb
Imports System.Xml.Serialization
Imports System.IO
Public Class SettingSer
Public Shared _filename As String = Constants.WEB_SERVICE_SETTING_SER_FILE
Public _ADXOIFormSendOption As Integer
Public _PathForm_Destination As String
Public _PathForm_DirectoryID As Integer
Public _PathForm_ExportTypeOption As Integer
Public _PathForm_emailExport As Boolean
Public _PathForm_attachmentExport As Boolean
Public _PathForm_attachmentsUnderEmailSubjectDirectory As Boolean
Public _PathForm_directUpload As Boolean
Public _PathForm_ApplicationRawURL As String '原来的服务器地址
Public _PathForm_ApplicationNewURL As String '指定的服务器地址
Public _Profile_profileOptionsIndex As Integer
Public _Profile_applyingToRemaining As Boolean
Public _Profile_applyToAllChecked As Boolean
Public _DefaultUploadFolder_SettingEnabled As Boolean
Public _DefaultUploadFolder_Destination As String
Public _DefaultUploadFolder_DirectoryID As Integer
Public _DefaultUploadFolder_ExportTypeOption As Integer
Public _DefaultUploadFolder_emailExport As Boolean
Public _DefaultUploadFolder_attachmentExport As Boolean
Public _DefaultUploadFolder_attachmentsUnderEmailSubjectDirectory As Boolean
Public Shared Function LoadSettingFromXml() As SettingSer
Dim stream As FileStream = Nothing
Try
Dim setting As SettingSer = Nothing
If File.Exists(_filename) Then
Dim info As FileInfo = New FileInfo(_filename)
If info.Length > 0 Then
Dim xmlSer As New XmlSerializer(GetType(SettingSer))
stream = File.OpenRead(_filename)
setting = xmlSer.Deserialize(stream)
End If
End If
Return setting
Catch ex As Exception
Throw ex
Finally
If Not stream Is Nothing Then
stream.Flush()
stream.Close()
End If
End Try
End Function
Public Shared Sub SaveSettingToXml(ByRef setting)
Dim stream As FileStream = Nothing
Try
If Not Directory.Exists(Constants.APPLICATION_DATA) Then
Directory.CreateDirectory(Constants.APPLICATION_DATA)
End If
Dim xmlSer As New XmlSerializer(GetType(SettingSer))
stream = File.Open(_filename, FileMode.Create, FileAccess.Write)
xmlSer.Serialize(stream, setting)
Catch ex As Exception
Throw ex
Finally
If Not stream Is Nothing Then
stream.Flush()
stream.Close()
End If
End Try
End Sub
Public Sub New()
_ADXOIFormSendOption = 0
_PathForm_Destination = ""
_PathForm_DirectoryID = 0
_PathForm_ExportTypeOption = 0
_PathForm_emailExport = True
_PathForm_attachmentExport = False
_PathForm_attachmentsUnderEmailSubjectDirectory = False
_PathForm_directUpload = False
_Profile_profileOptionsIndex = 0
_Profile_applyingToRemaining = False
_Profile_applyToAllChecked = False
_PathForm_ApplicationRawURL = ""
_PathForm_ApplicationNewURL = ""
_DefaultUploadFolder_SettingEnabled = True
_DefaultUploadFolder_Destination = ""
_DefaultUploadFolder_DirectoryID = 0
_DefaultUploadFolder_ExportTypeOption = 0
_DefaultUploadFolder_emailExport = True
_DefaultUploadFolder_attachmentExport = False
_DefaultUploadFolder_attachmentsUnderEmailSubjectDirectory = False
End Sub
End Class
/ Email / EmailAttachment.vb
Public Class EmailAttachment
Inherits EmailContentsBody
Private appendix As Outlook.Attachment
Private shelteredDirectory As String
Private attachmentOrder As Integer
Public Sub New(ByVal letter As Outlook.MailItem, ByVal parent As Integer, ByVal order As Integer, ByVal itemIndex As Integer, ByVal underShelteredDirectory As Boolean, ByVal savedName As String, ByVal area As String, ByVal information As String, ByVal subsidiary As Outlook.Attachment, ByVal shieldingDirectory As String, ByVal attachmentSequence As Integer)
MyBase.New(letter, parent, order, itemIndex, underShelteredDirectory, savedName, area, information)
appendix = subsidiary
shelteredDirectory = shieldingDirectory
fileType = Constants.EMAIL_ATTACHMENT_FILE_TYPE
attachmentOrder = attachmentSequence
End Sub
Public Sub New(ByVal letter As Outlook.ReportItem, ByVal parent As Integer, ByVal order As Integer, ByVal itemIndex As Integer, ByVal underShelteredDirectory As Boolean, ByVal savedName As String, ByVal area As String, ByVal information As String, ByVal subsidiary As Outlook.Attachment, ByVal shieldingDirectory As String, ByVal attachmentSequence As Integer)
MyBase.New(letter, parent, order, itemIndex, underShelteredDirectory, savedName, area, information)
appendix = subsidiary
shelteredDirectory = shieldingDirectory
fileType = Constants.EMAIL_ATTACHMENT_FILE_TYPE
attachmentOrder = attachmentSequence
End Sub
Public Function getAppendix() As Outlook.Attachment
Return appendix
End Function
Public Sub setAppendix(ByVal letter As Outlook.Attachment)
appendix = letter
End Sub
Public Function getShelteredDirectory() As String
Return shelteredDirectory
End Function
Public Sub setShelteredDirectory(ByVal shieldingDirectory As String)
shelteredDirectory = shieldingDirectory
End Sub
Public Overrides Function getFileSize() As Double
'getFileSize = Math.Round(appendix.Size / 1024, 2)
getFileSize = 0
End Function
Public Function getAttachmentOrder() As Integer
Return attachmentOrder
End Function
Public Sub setAttachmentOrder(ByVal order As Integer)
attachmentOrder = order
End Sub
End Class
/Email / EmailCOntentsBody.vb
Public Class EmailContentsBody
Protected underEmailSubjectDirectory As Boolean
Protected parentalDirectoryId, rank, sequenceNo As Integer
Protected fileName, position, messages, fileType, result As String
Protected email As Outlook.MailItem = Nothing
Protected report As Outlook.ReportItem = Nothing
Protected mailtype As Integer = 0
Public Sub New(ByVal letter As Outlook.MailItem, ByVal parent As Integer, ByVal order As Integer, ByVal itemIndex As Integer, ByVal underShelteredDirectory As Boolean, ByVal savedName As String, ByVal area As String, ByVal information As String)
email = letter
parentalDirectoryId = parent
rank = order
sequenceNo = itemIndex
underEmailSubjectDirectory = underShelteredDirectory
fileType = Constants.MSG_FILE_TYPE
fileName = savedName
result = New String("")
position = area
messages = information
mailtype = 0
'InsertHyperLink()
End Sub
Public Sub New(ByVal letter As Outlook.ReportItem, ByVal parent As Integer, ByVal order As Integer, ByVal itemIndex As Integer, ByVal underShelteredDirectory As Boolean, ByVal savedName As String, ByVal area As String, ByVal information As String)
report = letter
parentalDirectoryId = parent
rank = order
sequenceNo = itemIndex
underEmailSubjectDirectory = underShelteredDirectory
fileType = Constants.MSG_FILE_TYPE
fileName = savedName
result = New String("")
position = area
messages = information
mailtype = 1
End Sub
'Public Sub InsertHyperLink()
' If Not email Is Nothing Then
' 'For index As Integer = 1 To email.Attachments.Count
' MsgBox(Me.email.HTMLBody.ToString)
' email.HTMLBody = Me.email.HTMLBody.Replace("</div>", "<div id=" & Chr(34) & "asta" & Chr(34) & " style=" & Chr(34) & "border: 3px; border-style:solid; color:#00000" & Chr(34) & "><p class=MsoNormal>Your attachement has been uploaded to DMS.</p><p class=MsoNormal></p><p class=MsoNormal>Click <a href=" _
' & Chr(34) & "http://hk.yahoo.com" & Chr(34) & ">Link 1<a> to store into your machine. ASTA</p><div></div>")
' MsgBox(Me.email.HTMLBody.ToString)
' ' Next
' End If
'End Sub
Public Function getPosition() As String
getPosition = position
End Function
Public Sub setPosition(ByVal place As String)
position = place
End Sub
Public Function getSubject() As String
If Not email Is Nothing Then
Return email.Subject
ElseIf Not report Is Nothing Then
Return report.Subject
Else
Return Nothing
End If
End Function
Public Function getGotDateTime() As Date
If Not email Is Nothing Then
Return email.ReceivedTime
ElseIf Not report Is Nothing Then
Return report.ReceivedTime
Else
Return Nothing
End If
End Function
Public Overridable Function getLogFileName() As String
Dim underscore, finalSubject As String
If Not email Is Nothing Then
underscore = New String("_")
finalSubject = CommonUtilities.replaceNullOrVacantEmailSubject(email.Subject)
finalSubject = CommonUtilities.removeIllegalDirectoryFileNameCharacters(finalSubject)
getLogFileName = finalSubject + underscore + email.ReceivedTime.ToString("yyyyddMMHHmmss") + underscore
ElseIf Not report Is Nothing Then
underscore = New String("_")
finalSubject = CommonUtilities.replaceNullOrVacantEmailSubject(report.Subject)
finalSubject = CommonUtilities.removeIllegalDirectoryFileNameCharacters(finalSubject)
getLogFileName = finalSubject + underscore + report.ReceivedTime.ToString("yyyyddMMHHmmss") + underscore
Else
Return Nothing
End If
End Function
Public Overridable Function getResultFileNamePrefix() As String
Dim underscore, finalSubject As String
If Not email Is Nothing Then
underscore = New String("_")
finalSubject = CommonUtilities.replaceNullOrVacantEmailSubject(email.Subject)
finalSubject = CommonUtilities.removeIllegalDirectoryFileNameCharacters(finalSubject)
getResultFileNamePrefix = finalSubject + underscore + fileName + underscore + email.ReceivedTime.ToString("ddMMyyyyHHmmss") + underscore
ElseIf Not report Is Nothing Then
underscore = New String("_")
finalSubject = CommonUtilities.replaceNullOrVacantEmailSubject(report.Subject)
finalSubject = CommonUtilities.removeIllegalDirectoryFileNameCharacters(finalSubject)
getResultFileNamePrefix = finalSubject + underscore + fileName + underscore + report.ReceivedTime.ToString("ddMMyyyyHHmmss") + underscore
Else
Return Nothing
End If
End Function
Public Function isUnderEmailSubjectDirectory() As Boolean
isUnderEmailSubjectDirectory = underEmailSubjectDirectory
End Function
Public Sub setUnderEmailSubjectDirectory(ByVal extraDirectory As Boolean)
underEmailSubjectDirectory = extraDirectory
End Sub
Public Function getFileName() As String
getFileName = fileName
End Function
Public Sub setFileName(ByVal name As String)
fileName = name
End Sub
Public Overridable Function getFileSize() As Double
If Not email Is Nothing Then
getFileSize = Math.Round(email.Size / 1024, 2)
ElseIf Not report Is Nothing Then
getFileSize = Math.Round(report.Size / 1024, 2)
Else : Return 0
End If
End Function
Public Function getLastUpdateDateTime() As Date
If Not email Is Nothing Then
getLastUpdateDateTime = email.LastModificationTime
ElseIf Not report Is Nothing Then
getLastUpdateDateTime = report.LastModificationTime
Else : Return Now
End If
End Function
Public Function getRank() As Integer
getRank = rank
End Function
Public Sub setRank(ByVal order As Integer)
rank = order
End Sub
Public Function getEmail() As Outlook.MailItem
Return email
End Function
Public Function getReport() As Outlook.ReportItem
Return report
End Function
Public Sub setEmail(ByVal letter As Outlook.MailItem)
email = letter
End Sub
Public Function getParentalDirectoryId() As Integer
Return parentalDirectoryId
End Function
Public Sub setParentalDirectoryId(ByVal parent As Integer)
parentalDirectoryId = parent
End Sub
Public Function getSequenceNo() As Integer
Return sequenceNo
End Function
Public Sub setSequenceNo(ByVal itemIndex As Integer)
sequenceNo = itemIndex
End Sub
Public Function getMessages() As String
Return messages
End Function
Public Sub setMessages(ByVal information As String)
messages = information
End Sub
Public Function getFileType() As String
Return fileType
End Function
Public Function getResult() As String
Return result
End Function
Public Sub setResult(ByVal consequence As String)
result = consequence
End Sub
Public Function getMailtype() As Integer
getMailtype = mailtype
End Function
End Class
Когда я попытался отладить его, например, отправив электронное письмо, первый раз прошел гладко, но мне нужно дважды нажать кнопку "Отправить" второй раз, как это.
Видео кнопки двойного щелчка Может кто-нибудь, пожалуйста, любезно расскажите, что происходит.
Спасибо.