|
MS Exchange needs to be configured for SMTP and POP3 - that is not active by default.
If your program still fails, show us the code and the exact error message.
|
|
|
|
|
Thanks Bernhard,
the code as below
Imports System.Net.Mail
Imports System.Net
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Text = "Taher Shaker Mailer"
End Sub
Private Sub BtnSend_Click(sender As Object, e As EventArgs) Handles BtnSend.Click
Dim MyMessage As New MailMessage()
MyMessage.From = New MailAddress("myemail@company.com")
MyMessage.To.Add("another@gmail.com")
MyMessage.Subject = "my subject"
MyMessage.Body = "my message body"
Dim MyNetworkCredential As New NetworkCredential
MyNetworkCredential.Domain = "companyserver.com"
MyNetworkCredential.UserName = "myusername"
MyNetworkCredential.Password = "mypassword"
Try
Dim MySmtpClient As New SmtpClient()
MySmtpClient.Host = "https://companyserver.com"
MySmtpClient.Credentials = MyNetworkCredential
MySmtpClient.Send(MyMessage)
Catch ex As SmtpException
MessageBox.Show(ex.ToString)
Exit Sub
End Try
End Sub
also the error as below:
System.net.mail.smtpException: Failure sending mail
|
|
|
|
|
|
In a vb.net 2010 application, I have just written the following code where data is obtained from the database and stored in the dataset called _dtreasonsnonattendance.
dim String columnname
For i = 0 To _dtreasonsnonattendance.Rows.Count() - 1
columnname = _dtreasonsnonattendance.Rows(i)(_dtreasonsnonattendance.Columns(7).ColumnName()).ToString()
next
In the part of the statement listed above, when I hover over the 'ColumnName()' part of the statement listed above, I see the actual column name. I want the assignment statement to actually obtain the column name. Thus would you show me the code on how I can accomplish my goal?
|
|
|
|
|
Ignoring the fact that your code won't even compile, from the description you just want:
Dim columnName As String = _dtreasonsnonattendance.Columns(7).ColumnName
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
0
down vote
favorite
I have tried the following code copied from various websites but I am no programmer. I want the image to load at the right hand side of the screen in Word opposite the cursor position. Currently it loads at the top of the document or the centre of the first page if I use .Top = wdShapeCenter
The code is as follows:
Sub Apic()
Dim openDialog As Office.FileDialog
Dim shp As Shape
Set openDialog = Application.FileDialog(msoFileDialogFilePicker)
openDialog.Filters.Clear
openDialog.Filters.Add "JPEG Files", "*.jpg"
openDialog.Filters.Add "Gif Files", "*.gif"
openDialog.Filters.Add "PNG Files", "*.png"
openDialog.Filters.Add "All Files", "*.*"
If openDialog.Show Then
imageName = openDialog.SelectedItems(1)
End If
Set shp = ActiveDocument.Shapes.AddPicture( _
FileName:=imageName, _
SaveWithDocument:=True, _
Anchor:=ActiveDocument.Paragraphs(1).Range)
With shp
.Name = "PictureInsert"
.LockAspectRatio = True
.WrapFormat.AllowOverlap = False
.WrapFormat.Side = wdWrapTight
.WrapFormat.Type = 1
.RelativeHorizontalPosition = _
wdRelativeVerticalPositionMargin
.RelativeVerticalPosition = _
wdRelativeVerticalPositionMargin
.Left = wdShapeRight
' .Top = wdShapeCenter
End With
End Sub
vba word
|
|
|
|
|
99Freddo wrote: Anchor:=ActiveDocument.Paragraphs(1).Range
That's most likely the culprit - you're telling Word to anchor the shape to the first paragraph in the document.
Try changing that to:
Anchor := Selection.Paragraphs(1).Range
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks Richard. I've now got it working the full code is:
Sub zPic()
Dim openDialog As Office.FileDialog
Dim shp As Shape
Dim ils As InlineShape
Set openDialog = Application.FileDialog(msoFileDialogFilePicker)
openDialog.Filters.Clear
openDialog.Filters.Add "JPEG Files", "*.jpg"
openDialog.Filters.Add "Gif Files", "*.gif"
openDialog.Filters.Add "PNG Files", "*.png"
openDialog.Filters.Add "All Files", "*.*"
If openDialog.Show Then
imageName = openDialog.SelectedItems(1)
End If
Set shp = ActiveDocument.Shapes.AddPicture( _
FileName:=imageName, _
SaveWithDocument:=True, _
Anchor:=Selection.Range)
With shp
.WrapFormat.Type = wdWrapTight
.RelativeVerticalPosition = wdRelativeVerticalPositionMargin
.RelativeHorizontalPosition = wdRelativeHorizontalPositionMargin
.Left = wdFrameRight
End With
End Sub
|
|
|
|
|
In a change to a .net 2010 application that uses a sql server 2012 database, I am thinking of using a trigger when a duplicate record has been generated. This trigger would send outlook 2013 or office 365 email message to selected users. I am thinking of doing this instead of having the duplicate record email message sent out in the .net application. Thus would you show me the code and/or point me to a url that will show me how to accomplish my goal?
|
|
|
|
|
You should know by now that "show me the code" does not work here.
As SQL Server is a SERVER application and Office is a CLIENT application you are not going to be able to do as you require unless you install Office on your server (not sure this can even be done!).
From the server you need to use SMTP for SQL server to send mail notifications.
Sending a notification that a duplicate record has been created indicates you have a badly designed database. Duplicates should be dealt with either before or during the insert, NEVER after insert.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The SQL server can send mail directly if you have Database mail configured, but it does not uses Outlook or Webmail. This can be done from a trigger, agen job or procedure
email - Send e-mail from a trigger - Stack Overflow[^]
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
In an existing vb.net 2010 application, I would like to create an email message for selected users using outlook 2013 and/or webmail that is supported by office 365. This email message would be generated when a user clicks a button to have a 'letter' generated. This email message would be generated when duplicate rec ords are located in the sql server 2012 database. The duplicate records should not occur in 99% of the cases but there is a chance the duplicate record can happen.
Thus would you show me the code on how to generate this email message?
|
|
|
|
|
|
Hello !
I have a sql server database ( the model ).
I have another sql server database.
I want to compare the second database with the model , and after to update the database structure in order to be equal with the model.
Is there any way to do this with VB.net
Thank you !
|
|
|
|
|
Yes but it is probably beyond your skill set at the moment. You might want to get SQL Compare from Red-Gate to give you an idea of the scope of this requirement. Red-Gate is not free but they are good, you might find some free tools to do a similar job, you might search Free Tools Discussion Boards[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I don't want a tool to make this work.
I know the redgate sql compare. But I think this tool work as a standalone program.
I need a library or a way to do this through code inside my vb.net program.
|
|
|
|
|
|
Thank you , but I'm not using Entity Framework on my program.
Do you think I can use this only for comparing databases and reflect changes ?
|
|
|
|
|
Have some google foo[^] it looks like there are quite a few examples there, even one from CP.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You can automate this with SQL Compare within a VB.NET program. There is a Compare SDK that can be embedded into an application.
SQL Comparison SDK - Automates Comparison And Synchronization Tasks[^]
The process of comparing two tables and generating difference code isn't hard, but it does become tedious as there are a lot of potential issues to work through. If you have lots of time to build this, then you can use data from sys.columns and other DMVs to generate difference lists and build the ALTER statements for tables.
For views/procs/functions, it's more complex comparing changes, but really if you have a model, you can just take the code and move it over.
|
|
|
|
|
Hello !
Using vb.net , how can I search and list the sql server instances running on local Pc and on local network ?
For each sql server instance I need to know the server name and database instance name.
Thank you !
|
|
|
|
|
|
Thank you !
But , is this going to work with other version of sql server for example 2012 , 2014 or 2016 ?
|
|
|
|
|