【问题标题】:VB.Net Email not putting copy in sent folderVB.Net 电子邮件未将副本放入已发送文件夹
【发布时间】:2020-07-16 19:15:39
【问题描述】:

我要疯了!

在 VB.Net 中发送电子邮件工作正常,甚至读取/发送收据也工作正常。它做的是把它发送的电子邮件的副本放在已发送的文件夹中。还有什么我需要做的吗,因为我一直在寻找解决方案,但什么也看不到。

                        EMail.From = New MailAddress(sSENDERaddress)
                        EMail.Body = sMessage
                        EMail.Subject = sSubject

                        If sAttached <> "" Then
                            Dim mAttachment As New Attachment(sAttached)
                            EMail.Attachments.Add(mAttachment)
                        End If
                        EMail.Headers.Add("Return-Receip-To", sSENDERaddress)
                        EMail.Headers.Add("Disposition-Notification-To", sSENDERaddress)
                        EMail.Headers.Add("Return-Path", sSENDERaddress)
                        EMail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure Or DeliveryNotificationOptions.OnSuccess ' this will send an email to the SENDER'S email address confirming that the original email was sent. If the sender doesn't get the email, then it didn't go. Simples
                        SMTPServer.Host = GetMailServerAddress()
                        SMTPServer.Port = GetMailPort()
                        SMTPServer.Credentials = Authentication 
                        Try
                            SMTPServer.Send(EMail)
                            'EMail.Dispose()
                            bRET = True
                        Catch ex As Exception
                            ''debug.Print(ex.Message)
                            ExceptIt(ex.Message)
                            'EMail.Dispose()
                            bRET = False
                        End Try

【问题讨论】:

    标签: vb.net email


    【解决方案1】:

    我发现了更多关于这个主题的帖子,看起来你做不到。唯一的 Heath Robinson 解决方案是在我的发送地址中添加密件抄送...

    更新:对于那些感兴趣的人,它不是 SMTP 功能,而是 IMAP 功能。我想,如果你愿意,你可以花几个小时为此编写代码,但我发现了这个

    https://www.example-code.com/vbnet/sendWithCopyToSentMailbox.asp

    您只需附加到发送的项目...

    '  Now use Chilkat IMAP to save the email to Inbox.Sent
    
    Dim imap As New Chilkat.Imap
    
    '  Connect to an IMAP server.
    '  Use TLS
    imap.Ssl = True
    imap.Port = 993
    success = imap.Connect("mail.mydomain.com")
    If (success <> True) Then
        Console.WriteLine(imap.LastErrorText)
        Exit Sub
    End If
    
    
    '  Login
    success = imap.Login("myLogin","myPassword")
    If (success <> True) Then
        Console.WriteLine(imap.LastErrorText)
        Exit Sub
    End If
    
    
    '  The AppendMail method uploads an email to an IMAP server
    '  and saves it in the mailbox specified:
    success = imap.AppendMail("Inbox.Sent",email)
    If (success <> True) Then
        Console.WriteLine(imap.LastErrorText)
        Exit Sub
    End If
    
    
    Console.WriteLine("Mail saved to Inbox.Sent")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-05
      • 2012-06-14
      • 2012-07-10
      • 2016-11-29
      • 2019-08-03
      • 2011-03-13
      • 2021-03-24
      • 1970-01-01
      相关资源
      最近更新 更多