从VB.Net应用程序发送带有图像的MMS消息 [英] Sending MMS messages with images from VB.Net application

查看:59
本文介绍了从VB.Net应用程序发送带有图像的MMS消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的应用程序中有一个使用网络摄像头拍照的表格,然后通过电子邮件,短信和/或彩信通过电子邮件到短信和电子邮件到彩信的网关将图片作为附件发送用户的安全警报偏好设置.   The 我遇到的问题是我的代码可以很好地将电子邮件的文本发送到所有三个(电子邮件,SMS和MMS),并且可以通过电子邮件成功发送图片,但是当MMS到达时,图片就无法发送随附的.  

I have in my application a form which uses the webcam to take a picture and then sends the picture as an attachment via email, sms, and/or mms through email-to-sms and email-to-mms gateways, depending on the user's security alerts preferences.  The problem I'm having is that my code works fine to send the text of the email message to all three (Email, SMS, and MMS), and it successfully sends the picture via email, but when the MMS arrives, the picture is not attached.  

有什么想法要解决吗?

这是有问题的潜艇:

 Private Sub SendAlerts()
        Queried_Profile = GetSetting(Application.CompanyName, Application.ProductName, "Queried_Profile")
        Last_Security_Pic = GetSetting(Application.CompanyName, Application.ProductName, "Last_Security_Pic")
        Dim DB As New Reader
        With DB
            .ProfileName = Queried_Profile
            If .UserEmailEnabled = True Then
                Dim SmtpServer As New SmtpClient()
                SmtpServer.Credentials = New Net.NetworkCredential("notarealemail@address.com", "fakepassword")
                SmtpServer.Port = 587
                SmtpServer.Host = "smtp.gmail.com"
                SmtpServer.EnableSsl = True
                Dim mail As New MailMessage()
                mail = New MailMessage()
                mail.From = New MailAddress("notarealemail@address.com", "ShadowCorp™ Services", System.Text.Encoding.UTF8)
                mail.To.Add(.EmailAddress.ToString)
                mail.Subject = "TattleTale Alert: Unauthorized Access Attempt"
                mail.Body = Queried_Profile & ", you are receiving this message because an unauthorized login attempt has been made to your " & Application.ProductName & " profile. If you have a webcam and the appropriate settings enabled, a photo of the guilty party is attached. For your security, your profile has been locked. To unlock it, attempt to login and follow the onscreen instructions." & Chr(13) & Chr(13) & "ShadowCorp™"
                If Not String.IsNullOrEmpty(Last_Security_Pic) Then
                    mail.Attachments.Add(New Attachment(Last_Security_Pic))
                End If
                mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
                SmtpServer.Send(mail)
            End If
            If .UserSMSEnabled = True Then
                Dim SmtpServer As New SmtpClient()
                SmtpServer.Credentials = New Net.NetworkCredential("notarealemail@address.com", "fakepassword")
                SmtpServer.Port = 587
                SmtpServer.Host = "smtp.gmail.com"
                SmtpServer.EnableSsl = True
                Dim mail As New MailMessage()
                mail = New MailMessage()
                mail.From = New MailAddress("notarealemail@address.com", "ShadowCorp™ Services", System.Text.Encoding.UTF8)
                mail.To.Add(.SMSAddress.ToString)
                mail.Subject = "TattleTale Alert: Unauthorized Access Attempt"
                mail.Body = Queried_Profile & ", you are receiving this message because an unauthorized login attempt has been made to your " & Application.ProductName & " profile. If you have a webcam and the appropriate settings enabled, a photo of the guilty party is attached. For your security, your profile has been locked. To unlock it, attempt to login and follow the onscreen instructions." & Chr(13) & Chr(13) & "ShadowCorp™"
                If Not String.IsNullOrEmpty(Last_Security_Pic) Then
                    mail.Attachments.Add(New Attachment(Last_Security_Pic))
                End If
                mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
                SmtpServer.Send(mail)
            End If
            If .UserMMSEnabled = True Then
                Dim SmtpServer As New SmtpClient()
                SmtpServer.Credentials = New Net.NetworkCredential("notarealemail@address.com", "fakepassword")
                SmtpServer.Port = 587
                SmtpServer.Host = "smtp.gmail.com"
                SmtpServer.EnableSsl = True
                Dim mail As New MailMessage()
                mail = New MailMessage()
                mail.From = New MailAddress("notarealemail@address.com", "ShadowCorp™ Services", System.Text.Encoding.UTF8)
                mail.To.Add(.MMSAddress.ToString)
                mail.Subject = "TattleTale Alert: Unauthorized Access Attempt"
                mail.Body = Queried_Profile & ", you are receiving this message because an unauthorized login attempt has been made to your " & Application.ProductName & " profile. If you have a webcam and the appropriate settings enabled, a photo of the guilty party is attached. For your security, your profile has been locked. To unlock it, attempt to login and follow the onscreen instructions." & Chr(13) & Chr(13) & "ShadowCorp™"
                If Not String.IsNullOrEmpty(Last_Security_Pic) Then
                    mail.Attachments.Add(New Attachment(Last_Security_Pic))
                End If
                mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
                SmtpServer.Send(mail)
            End If
            .Dispose()
        End With
    End Sub

谢谢!

Jason

推荐答案

您需要与服务提供商(即网关)进行检查,他们应该告诉您网关失败的原因或向您提供示例代码段.
You need to check with the service provider i.e the Gateway, and they should tell you why its failing or provide you with a sample code snippet.


这篇关于从VB.Net应用程序发送带有图像的MMS消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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