-
Feb 17th, 2015, 02:00 PM
#1
Thread Starter
Addicted Member
can send e-mails in VBA but not VB.net
I have code which sends e-mails in VBA and also in VB.net. My computers got upgraded to outlook 2013 so I updated my object library references. My VBA will send e-mails just fine but my VB.net stops working. What can I do to fix my VB.net?
This will create the e-mail, fill it out correctly, display it, but when it gets to .send() it stops working.
I can manually click send on the displayed e-mail and it sends just fine.
Code:
Public Sub e_mail()
Dim olapp As Interop.Outlook.Application
Dim olmail As Interop.Outlook.MailItem
olapp = CreateObject("outlook.application")
olmail = olapp.CreateItem(OlItemType.olMailItem)
With olmail
.BodyFormat = OlBodyFormat.olFormatHTML
.To = email
.Subject = drname & " MCR O2 documents needed."
.HTMLBody = ("test")
.SentOnBehalfOfName = "APRIA MCR 02"
.Display()
.Send()
End With
End Sub
.send() throws this error:
"The operation failed. The messaging interfaces have returned an unknown error. If the problem persists, restart Outlook. Cannot resolve recipient."
If I manually click send on the e-mail it works just fine so it's not a size or recipient issue. Also e-mails are being sent just fine via VBA using this code:
Code:
Public Sub E_mail ()
Set olApp = CreateObject("Outlook.Application")
Set OlMail = olApp.CreateItem(olMailItem)
With OlMail
.to = "test_email@gmail.com"
.SentOnBehalfOfName = "APRIA MCR 02"
.Subject = "File ready for CO Medicaid claim cleaning "
.send
End With
End Sub
-
Feb 17th, 2015, 02:17 PM
#2
Re: can send e-mails in VBA but not VB.net
Why don't you use a PHP mailer to send the email?
-
Feb 17th, 2015, 02:26 PM
#3
Thread Starter
Addicted Member
Re: can send e-mails in VBA but not VB.net
Originally Posted by Toph
Why don't you use a PHP mailer to send the email?
I don't know how to. My company uses microsoft outlook.
-
Feb 17th, 2015, 02:40 PM
#4
Re: can send e-mails in VBA but not VB.net
My guess is the Outlook Security Warning is being triggered because it is an untrusted app. doing the sending. The linked article will explain what to do.
-
Feb 17th, 2015, 03:13 PM
#5
Thread Starter
Addicted Member
Re: can send e-mails in VBA but not VB.net
Originally Posted by Merrion
My guess is the Outlook Security Warning is being triggered because it is an untrusted app. doing the sending. The linked article will explain what to do.
nope. I can send e-mails in VBA without any security issues.
-
Feb 18th, 2015, 03:32 PM
#6
Re: can send e-mails in VBA but not VB.net
Where is email(in the line: .To = email) declared, and what does it contain when run?
-
Feb 24th, 2015, 03:00 PM
#7
Thread Starter
Addicted Member
Re: can send e-mails in VBA but not VB.net
Originally Posted by Merrion
Where is email(in the line: .To = email) declared, and what does it contain when run?
The e-mail address contains the e-mail variable from the data file that the e-mail is to be sent to. I know it's a valid e-mail because after the code creates the e-mail and makes it visible I can manually click send and the e-mail will send with no problems. It's declared as a public module level string variable.
-
Feb 24th, 2015, 03:01 PM
#8
Thread Starter
Addicted Member
Re: can send e-mails in VBA but not VB.net
Originally Posted by Merrion
My guess is the Outlook Security Warning is being triggered because it is an untrusted app. doing the sending. The linked article will explain what to do.
I tried it and it still does not work.
-
Feb 27th, 2015, 02:35 PM
#9
Thread Starter
Addicted Member
Re: can send e-mails in VBA but not VB.net
Anyone have an ideas about how I can fix this?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|